Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
|
@@ -9,7 +9,6 @@ import time
|
|
| 9 |
import base64
|
| 10 |
|
| 11 |
from agent import *
|
| 12 |
-
from app_playground import response
|
| 13 |
|
| 14 |
# (Keep Constants as is)
|
| 15 |
# --- Constants ---
|
|
@@ -27,25 +26,24 @@ class BasicAgent:
|
|
| 27 |
def __call__(self, question: str, content=None, content_type= None) -> str:
|
| 28 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 29 |
if content_type == "image/png":
|
|
|
|
| 30 |
image = base64.b64encode(content).decode("utf-8")
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
],
|
| 46 |
-
}
|
| 47 |
-
response = self.graph.invoke(message)
|
| 48 |
else :
|
|
|
|
| 49 |
response = self.graph.invoke({"messages": [HumanMessage(content=question),]})
|
| 50 |
|
| 51 |
print("Agents answert to the question: ",response["messages"][-1].content)
|
|
|
|
| 9 |
import base64
|
| 10 |
|
| 11 |
from agent import *
|
|
|
|
| 12 |
|
| 13 |
# (Keep Constants as is)
|
| 14 |
# --- Constants ---
|
|
|
|
| 26 |
def __call__(self, question: str, content=None, content_type= None) -> str:
|
| 27 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 28 |
if content_type == "image/png":
|
| 29 |
+
# Convert the image to base64
|
| 30 |
image = base64.b64encode(content).decode("utf-8")
|
| 31 |
+
# Create message with the image
|
| 32 |
+
question_with_png = [{
|
| 33 |
+
"type": "text",
|
| 34 |
+
"text": question},
|
| 35 |
+
{
|
| 36 |
+
"type": "image",
|
| 37 |
+
"source_type": "base64",
|
| 38 |
+
"data": image,
|
| 39 |
+
"mime_type": "image/png",
|
| 40 |
+
|
| 41 |
+
},
|
| 42 |
+
]
|
| 43 |
+
# Invoke the graph with the image
|
| 44 |
+
response = self.graph.invoke({"messages": [HumanMessage(content=question_with_png),]})
|
|
|
|
|
|
|
|
|
|
| 45 |
else :
|
| 46 |
+
# Invoke the graph with the question
|
| 47 |
response = self.graph.invoke({"messages": [HumanMessage(content=question),]})
|
| 48 |
|
| 49 |
print("Agents answert to the question: ",response["messages"][-1].content)
|