Spaces:
Runtime error
Runtime error
Fixing - TypeError: stream_to_gradio() got an unexpected keyword argument 'data_file'
#2
by
dsTon
- opened
app.py
CHANGED
|
@@ -16,7 +16,7 @@ model = HfApiModel("Qwen/Qwen2.5-Coder-32B-Instruct")
|
|
| 16 |
agent = CodeAgent(
|
| 17 |
tools=[],
|
| 18 |
model=model,
|
| 19 |
-
additional_authorized_imports=["numpy", "pandas", "matplotlib.pyplot", "seaborn", "scipy.stats"],
|
| 20 |
max_steps=10,
|
| 21 |
)
|
| 22 |
|
|
@@ -77,14 +77,15 @@ def interact_with_agent(file_input, additional_notes):
|
|
| 77 |
if additional_notes and len(additional_notes) > 0:
|
| 78 |
prompt += "\nAdditional notes on the data:\n" + additional_notes
|
| 79 |
|
| 80 |
-
|
| 81 |
-
yield messages + [
|
| 82 |
-
gr.ChatMessage(role="assistant", content="β³ _Starting task..._")
|
| 83 |
-
]
|
| 84 |
|
|
|
|
|
|
|
| 85 |
plot_image_paths = {}
|
| 86 |
-
|
|
|
|
| 87 |
messages.append(msg)
|
|
|
|
| 88 |
for image_path in get_images_in_directory("./figures"):
|
| 89 |
if image_path not in plot_image_paths:
|
| 90 |
image_message = gr.ChatMessage(
|
|
@@ -93,9 +94,11 @@ def interact_with_agent(file_input, additional_notes):
|
|
| 93 |
)
|
| 94 |
plot_image_paths[image_path] = True
|
| 95 |
messages.append(image_message)
|
|
|
|
| 96 |
yield messages + [
|
| 97 |
gr.ChatMessage(role="assistant", content="β³ _Still processing..._")
|
| 98 |
]
|
|
|
|
| 99 |
yield messages
|
| 100 |
|
| 101 |
|
|
|
|
| 16 |
agent = CodeAgent(
|
| 17 |
tools=[],
|
| 18 |
model=model,
|
| 19 |
+
additional_authorized_imports=["numpy", "pandas", "matplotlib.pyplot", "seaborn", "scipy.stats", "os", "shutil",],
|
| 20 |
max_steps=10,
|
| 21 |
)
|
| 22 |
|
|
|
|
| 77 |
if additional_notes and len(additional_notes) > 0:
|
| 78 |
prompt += "\nAdditional notes on the data:\n" + additional_notes
|
| 79 |
|
| 80 |
+
prompt += "\n\nNOTE: The data is already loaded as 'data_file' in the Python interpreter. Use this directly without reloading."
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
+
messages = [gr.ChatMessage(role="user", content=prompt)]
|
| 83 |
+
yield messages + [gr.ChatMessage(role="assistant", content="β³ _Starting task..._")]
|
| 84 |
plot_image_paths = {}
|
| 85 |
+
additional_args = {"data_file": data_file}
|
| 86 |
+
for msg in stream_to_gradio(agent, prompt, additional_args=additional_args):
|
| 87 |
messages.append(msg)
|
| 88 |
+
|
| 89 |
for image_path in get_images_in_directory("./figures"):
|
| 90 |
if image_path not in plot_image_paths:
|
| 91 |
image_message = gr.ChatMessage(
|
|
|
|
| 94 |
)
|
| 95 |
plot_image_paths[image_path] = True
|
| 96 |
messages.append(image_message)
|
| 97 |
+
|
| 98 |
yield messages + [
|
| 99 |
gr.ChatMessage(role="assistant", content="β³ _Still processing..._")
|
| 100 |
]
|
| 101 |
+
|
| 102 |
yield messages
|
| 103 |
|
| 104 |
|