Manavraj's picture
Update app.py
5d17291 verified
raw
history blame
1.28 kB
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)