File size: 2,857 Bytes
d428a48 e0fb937 f5f16c7 d428a48 999a29a 9a84850 999a29a 9a84850 0f4d5d3 958b90b f5f16c7 958b90b b0c0b87 307635e 2b21b0f 307635e 2b21b0f 9a84850 f5f16c7 9a84850 f5f16c7 2b21b0f 9a84850 d152099 307635e |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
import gradio as gr
from llm_handler import sanchaari
import time
def handle_query(query):
thoughts = []
final_answer = None
for result in sanchaari(query):
if "thought" in result:
thoughts.append(result["thought"])
yield query, "\n".join(thoughts), ""
if "final_answer" in result:
final_answer = result["final_answer"]
yield query, "\n".join(thoughts), final_answer
def clear_outputs():
start_time = time.time()
result = ("", "", "")
end_time = time.time()
print(f"Clear operation took {end_time - start_time:.6f} seconds")
return result
with gr.Blocks(theme=gr.themes.Soft()) as demo:
gr.Markdown(
"""
# Antarjaala Sanchaari: Your Versatile AI Assistant
Meet **Antarjaala Sanchaari**, your intelligent companion for insightful answers and seamless assistance.
"""
)
with gr.Row():
with gr.Column(scale=1):
gr.Markdown(
"""
### What Sanchaari Can Do:
- **Calculate**: Perform arithmetic calculations
- **Find Information**: Search and summarize from Wikipedia
- **Tell Time**: Get current time worldwide
- **Get Stock Prices**: Check current stock prices
- **Define Words**: Look up word definitions
- **Provide Latest News**: Retrieve news headlines
- **Translate Text**: Translate from English
"""
)
with gr.Column(scale=1):
gr.Markdown(
"""
### Example Questions:
1. What is the capital of France?
2. Calculate 2*3
3. Define "serendipity"
4. Translate "Hello, how are you?" to Spanish
5. What's the current stock price of Apple?
6. What's the latest news about climate change?
7. What time is it in Tokyo right now?
"""
)
with gr.Row():
with gr.Column(scale=1):
query_input = gr.Textbox(
lines=5,
placeholder="Enter your query here...",
label="Your Question"
)
with gr.Row():
submit_btn = gr.Button("Ask Sanchaari", variant="primary")
clear_btn = gr.Button("Clear", variant="secondary")
response_output = gr.Textbox(label="Sanchaari's Response", lines=3)
thought_output = gr.Textbox(label="Thought Process", lines=10, scale=1)
submit_btn.click(handle_query, inputs=query_input, outputs=[query_input, thought_output, response_output])
clear_btn.click(clear_outputs, outputs=[query_input, thought_output, response_output])
demo.launch(share=True) |