Spaces:
Running
Running
Commit
·
3f0e775
1
Parent(s):
b0ab372
Update app and llm
Browse files
app.py
CHANGED
@@ -11,9 +11,6 @@ from llm import get_default_model
|
|
11 |
|
12 |
gr.set_static_paths(paths=["images/"])
|
13 |
|
14 |
-
master_agent = get_master_agent(get_default_model())
|
15 |
-
print(master_agent)
|
16 |
-
|
17 |
|
18 |
def resize_image(image):
|
19 |
width, height = image.size
|
@@ -27,6 +24,7 @@ def resize_image(image):
|
|
27 |
|
28 |
|
29 |
def chat_interface_fn(input_request, history: List[ChatMessage], gallery):
|
|
|
30 |
if gallery is None:
|
31 |
gallery = []
|
32 |
else:
|
@@ -58,7 +56,7 @@ def chat_interface_fn(input_request, history: List[ChatMessage], gallery):
|
|
58 |
resized_images = [resize_image(image) for image in images]
|
59 |
|
60 |
for message in stream_to_gradio(
|
61 |
-
|
62 |
task=prompt,
|
63 |
task_images=resized_images,
|
64 |
additional_args={"images": images},
|
@@ -67,7 +65,7 @@ def chat_interface_fn(input_request, history: List[ChatMessage], gallery):
|
|
67 |
history.append(message)
|
68 |
yield history, None
|
69 |
|
70 |
-
final_images =
|
71 |
gallery.extend(final_images)
|
72 |
yield history, gallery
|
73 |
|
|
|
11 |
|
12 |
gr.set_static_paths(paths=["images/"])
|
13 |
|
|
|
|
|
|
|
14 |
|
15 |
def resize_image(image):
|
16 |
width, height = image.size
|
|
|
24 |
|
25 |
|
26 |
def chat_interface_fn(input_request, history: List[ChatMessage], gallery):
|
27 |
+
agent = get_master_agent(get_default_model())
|
28 |
if gallery is None:
|
29 |
gallery = []
|
30 |
else:
|
|
|
56 |
resized_images = [resize_image(image) for image in images]
|
57 |
|
58 |
for message in stream_to_gradio(
|
59 |
+
agent,
|
60 |
task=prompt,
|
61 |
task_images=resized_images,
|
62 |
additional_args={"images": images},
|
|
|
65 |
history.append(message)
|
66 |
yield history, None
|
67 |
|
68 |
+
final_images = agent.python_executor.state.get("final_images", [])
|
69 |
gallery.extend(final_images)
|
70 |
yield history, gallery
|
71 |
|
llm.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
-
from smolagents import OpenAIServerModel, LiteLLMModel
|
2 |
import os
|
3 |
|
|
|
|
|
|
|
4 |
LOCAL_LLM_SETTINGS = {
|
5 |
"api_base": "http://127.0.0.1:1234/v1",
|
6 |
"api_key": "api-key",
|
@@ -14,8 +16,8 @@ assert ANTHROPIC_API_KEY is not None, "ANTHROPIC_API_KEY is not set"
|
|
14 |
|
15 |
def get_default_model():
|
16 |
model = LiteLLMModel(
|
17 |
-
model_id="claude-3-7-sonnet-20250219",
|
18 |
-
|
19 |
api_key=os.getenv("ANTHROPIC_API_KEY"),
|
20 |
# reasoning_effort="low",
|
21 |
)
|
|
|
|
|
1 |
import os
|
2 |
|
3 |
+
from smolagents import LiteLLMModel
|
4 |
+
|
5 |
+
|
6 |
LOCAL_LLM_SETTINGS = {
|
7 |
"api_base": "http://127.0.0.1:1234/v1",
|
8 |
"api_key": "api-key",
|
|
|
16 |
|
17 |
def get_default_model():
|
18 |
model = LiteLLMModel(
|
19 |
+
# model_id="claude-3-7-sonnet-20250219",
|
20 |
+
model_id="claude-3-5-haiku-latest",
|
21 |
api_key=os.getenv("ANTHROPIC_API_KEY"),
|
22 |
# reasoning_effort="low",
|
23 |
)
|