themissingCRAM
commited on
Commit
·
5756803
1
Parent(s):
6193310
blocks experiment
Browse files
app.py
CHANGED
@@ -1,7 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import os
|
4 |
-
from smolagents import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
from sqlalchemy import (
|
6 |
create_engine,
|
7 |
MetaData,
|
@@ -120,6 +127,9 @@ if __name__ == "__main__":
|
|
120 |
|
121 |
agent = CodeAgent(
|
122 |
tools=[sql_engine_tool],
|
|
|
|
|
|
|
123 |
model=model,
|
124 |
max_steps=1,
|
125 |
verbosity_level=1,
|
@@ -127,13 +137,14 @@ if __name__ == "__main__":
|
|
127 |
# agent.run("What is the average each customer paid?")
|
128 |
# GradioUI(agent).launch()
|
129 |
|
130 |
-
def enter_message(message, chat_history
|
131 |
print()
|
132 |
print("enter_message debug")
|
133 |
-
print(
|
134 |
-
print(
|
|
|
135 |
chat_history.append({"role": "user", "content": message})
|
136 |
-
x = agent
|
137 |
print(type(x))
|
138 |
print("\n\n\n", x, "\n\n\n")
|
139 |
return "", x
|
@@ -142,5 +153,5 @@ if __name__ == "__main__":
|
|
142 |
chatbot = gr.Chatbot(type="messages")
|
143 |
input = gr.Textbox()
|
144 |
button = gr.Button("reply")
|
145 |
-
button.click(enter_message, [input, chatbot
|
146 |
b.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import os
|
4 |
+
from smolagents import (
|
5 |
+
tool,
|
6 |
+
CodeAgent,
|
7 |
+
HfApiModel,
|
8 |
+
GradioUI,
|
9 |
+
MultiStepAgent,
|
10 |
+
stream_to_gradio,
|
11 |
+
)
|
12 |
from sqlalchemy import (
|
13 |
create_engine,
|
14 |
MetaData,
|
|
|
127 |
|
128 |
agent = CodeAgent(
|
129 |
tools=[sql_engine_tool],
|
130 |
+
# system_prompt="""
|
131 |
+
# You are a text to sql converter
|
132 |
+
# """,
|
133 |
model=model,
|
134 |
max_steps=1,
|
135 |
verbosity_level=1,
|
|
|
137 |
# agent.run("What is the average each customer paid?")
|
138 |
# GradioUI(agent).launch()
|
139 |
|
140 |
+
def enter_message(message, chat_history):
|
141 |
print()
|
142 |
print("enter_message debug")
|
143 |
+
print("engine", engine)
|
144 |
+
print("message:", message)
|
145 |
+
print("chat_history", chat_history)
|
146 |
chat_history.append({"role": "user", "content": message})
|
147 |
+
x = stream_to_gradio(agent, message, additional_args=dict(engine=engine))
|
148 |
print(type(x))
|
149 |
print("\n\n\n", x, "\n\n\n")
|
150 |
return "", x
|
|
|
153 |
chatbot = gr.Chatbot(type="messages")
|
154 |
input = gr.Textbox()
|
155 |
button = gr.Button("reply")
|
156 |
+
button.click(enter_message, [input, chatbot], [input, chatbot])
|
157 |
b.launch()
|