Manavraj commited on
Commit
721f63f
·
verified ·
1 Parent(s): 861c241

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -1,6 +1,9 @@
1
  import gradio as gr
2
 
3
  def search_knowledge_base(issue: str) -> str:
 
 
 
4
  if "wifi" in issue.lower():
5
  return "Check if your router is powered on. Restart your router. Try connecting again."
6
  elif "screen" in issue.lower():
@@ -8,26 +11,23 @@ def search_knowledge_base(issue: str) -> str:
8
  return "No predefined solution found in the knowledge base."
9
 
10
  def search_web(query: str) -> str:
 
 
 
11
  return f"(Simulated Web Result) Top search result for '{query}'."
12
 
13
  def format_response(raw_steps: str) -> str:
 
 
 
14
  steps = raw_steps.split(". ")
15
  steps = [f"{i+1}. {step.strip('.')}" for i, step in enumerate(steps) if step.strip()]
16
  return "\n".join(steps)
17
 
18
- # Create Gradio interfaces
19
- kb_tool = gr.Interface(fn=search_knowledge_base, inputs="text", outputs="text")
20
- web_tool = gr.Interface(fn=search_web, inputs="text", outputs="text")
21
- format_tool = gr.Interface(fn=format_response, inputs="text", outputs="text")
22
-
23
- # Mount apps using gr.mount_gradio_apps()
24
- demo = gr.mount_gradio_apps(
25
- apps=[
26
- (kb_tool, "/search_knowledge_base"),
27
- (web_tool, "/search_web"),
28
- (format_tool, "/format_response"),
29
- ]
30
- )
31
 
32
  if __name__ == "__main__":
33
- demo.launch(mcp_server=True)
 
1
  import gradio as gr
2
 
3
  def search_knowledge_base(issue: str) -> str:
4
+ """
5
+ Search the knowledge base for solutions related to the provided issue.
6
+ """
7
  if "wifi" in issue.lower():
8
  return "Check if your router is powered on. Restart your router. Try connecting again."
9
  elif "screen" in issue.lower():
 
11
  return "No predefined solution found in the knowledge base."
12
 
13
  def search_web(query: str) -> str:
14
+ """
15
+ Perform a simulated web search for the given query.
16
+ """
17
  return f"(Simulated Web Result) Top search result for '{query}'."
18
 
19
  def format_response(raw_steps: str) -> str:
20
+ """
21
+ Format the raw steps into a numbered list.
22
+ """
23
  steps = raw_steps.split(". ")
24
  steps = [f"{i+1}. {step.strip('.')}" for i, step in enumerate(steps) if step.strip()]
25
  return "\n".join(steps)
26
 
27
+ with gr.Blocks() as demo:
28
+ gr.Interface(fn=search_knowledge_base, inputs="text", outputs="text", title="Knowledge Base Search")
29
+ gr.Interface(fn=search_web, inputs="text", outputs="text", title="Web Search")
30
+ gr.Interface(fn=format_response, inputs="text", outputs="text", title="Response Formatter")
 
 
 
 
 
 
 
 
 
31
 
32
  if __name__ == "__main__":
33
+ demo.launch(mcp_server=True, share=True)