Spaces:
Runtime error
Runtime error
Charles Azam
commited on
Commit
·
7318c6b
1
Parent(s):
c759d25
works with yield
Browse files
src/deepengineer/backend/gradio_entry_point.py
CHANGED
|
@@ -1,7 +1,33 @@
|
|
| 1 |
-
import io
|
| 2 |
-
import sys
|
| 3 |
-
import time
|
| 4 |
import gradio as gr
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
| 6 |
from deepengineer.deepsearch.main_agent import main_search
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import asyncio
|
| 3 |
+
import threading
|
| 4 |
+
import time
|
| 5 |
+
from smolagents import Tool
|
| 6 |
from deepengineer.deepsearch.main_agent import main_search
|
| 7 |
+
import time
|
| 8 |
+
|
| 9 |
+
# Streaming runner
|
| 10 |
+
def run_agent(user_input):
|
| 11 |
+
for i in range(5):
|
| 12 |
+
yield (f"{i}", None)
|
| 13 |
+
time.sleep(1)
|
| 14 |
+
yield (None, f"Final answer: {user_input}")
|
| 15 |
+
|
| 16 |
+
# Build Gradio interface
|
| 17 |
+
with gr.Blocks() as demo:
|
| 18 |
+
gr.Markdown("## Agent Interface with Real-Time Tool Logging")
|
| 19 |
+
|
| 20 |
+
user_input = gr.Textbox(label="User Message")
|
| 21 |
+
agent_output = gr.Textbox(label="Agent Response")
|
| 22 |
+
log_output = gr.Textbox(label="Tool Invocation Log", interactive=False)
|
| 23 |
+
|
| 24 |
+
# Button with streaming
|
| 25 |
+
send_button = gr.Button("Send")
|
| 26 |
+
send_button.click(
|
| 27 |
+
fn=run_agent,
|
| 28 |
+
inputs=[user_input],
|
| 29 |
+
outputs=[agent_output, log_output],
|
| 30 |
+
)
|
| 31 |
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
demo.launch()
|