Spaces:
Runtime error
Runtime error
File size: 1,275 Bytes
140fcff f379bec f4ccfcb 721f63f f4ccfcb f379bec f4ccfcb 721f63f f4ccfcb f379bec f4ccfcb 721f63f f4ccfcb 25e0e45 721f63f 25e0e45 69aae5c 5d17291 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
def search_knowledge_base(issue: str) -> str:
"""
Search the knowledge base for solutions related to the provided issue.
"""
if "wifi" in issue.lower():
return "Check if your router is powered on. Restart your router. Try connecting again."
elif "screen" in issue.lower():
return "Adjust display cable. Update graphics drivers. Restart the system."
return "No predefined solution found in the knowledge base."
def search_web(query: str) -> str:
"""
Perform a simulated web search for the given query.
"""
return f"(Simulated Web Result) Top search result for '{query}'."
def format_response(raw_steps: str) -> str:
"""
Format the raw steps into a numbered list.
"""
steps = raw_steps.split(". ")
steps = [f"{i+1}. {step.strip('.')}" for i, step in enumerate(steps) if step.strip()]
return "\n".join(steps)
with gr.Blocks() as demo:
gr.Interface(fn=search_knowledge_base, inputs="text", outputs="text", title="Knowledge Base Search")
gr.Interface(fn=search_web, inputs="text", outputs="text", title="Web Search")
gr.Interface(fn=format_response, inputs="text", outputs="text", title="Response Formatter")
if __name__ == "__main__":
demo.launch(share=True) |