Update app.py
Browse files
app.py
CHANGED
@@ -69,17 +69,36 @@ def route_question(question, openai_key):
|
|
69 |
except Exception as e:
|
70 |
return f"Error: {str(e)}"
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
# Create Gradio interface
|
73 |
demo = gr.Interface(
|
74 |
fn=route_question,
|
75 |
inputs=[
|
76 |
-
gr.Textbox(label="Enter your question"),
|
77 |
-
gr.Textbox(label="OpenAI API Key", type="password")
|
78 |
],
|
79 |
outputs=gr.Textbox(label="Response"),
|
80 |
title="LangChain Router Demo",
|
81 |
-
description="This demo shows how routing works in LangChain. Ask questions about LangChain, OpenAI, or any other topic.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
)
|
83 |
|
84 |
if __name__ == "__main__":
|
85 |
-
demo.launch()
|
|
|
69 |
except Exception as e:
|
70 |
return f"Error: {str(e)}"
|
71 |
|
72 |
+
# Example questions for each category
|
73 |
+
example_questions = [
|
74 |
+
["What is LangChain and how does it work?", "your-api-key-here"],
|
75 |
+
["How do I use OpenAI's GPT models?", "your-api-key-here"],
|
76 |
+
["What is the capital of France?", "your-api-key-here"],
|
77 |
+
["Explain LangChain's routing capabilities", "your-api-key-here"],
|
78 |
+
["Tell me about OpenAI's latest developments", "your-api-key-here"]
|
79 |
+
]
|
80 |
+
|
81 |
# Create Gradio interface
|
82 |
demo = gr.Interface(
|
83 |
fn=route_question,
|
84 |
inputs=[
|
85 |
+
gr.Textbox(label="Enter your question", placeholder="Type your question here..."),
|
86 |
+
gr.Textbox(label="OpenAI API Key", type="password", placeholder="Enter your OpenAI API key")
|
87 |
],
|
88 |
outputs=gr.Textbox(label="Response"),
|
89 |
title="LangChain Router Demo",
|
90 |
+
description="""This demo shows how routing works in LangChain. Ask questions about LangChain, OpenAI, or any other topic.
|
91 |
+
|
92 |
+
Example questions you can try:
|
93 |
+
- What is LangChain and how does it work?
|
94 |
+
- How do I use OpenAI's GPT models?
|
95 |
+
- What is the capital of France?
|
96 |
+
- Explain LangChain's routing capabilities
|
97 |
+
- Tell me about OpenAI's latest developments
|
98 |
+
""",
|
99 |
+
examples=example_questions,
|
100 |
+
cache_examples=False
|
101 |
)
|
102 |
|
103 |
if __name__ == "__main__":
|
104 |
+
demo.launch()
|