Spaces:
Running
Running
Update agent/image_symptom_tool.py
Browse files- agent/image_symptom_tool.py +10 -9
agent/image_symptom_tool.py
CHANGED
|
@@ -1,24 +1,25 @@
|
|
| 1 |
from langchain_core.tools import tool
|
| 2 |
from gradio_client import Client
|
|
|
|
| 3 |
|
| 4 |
@tool
|
| 5 |
-
def analyze_symptom_image(
|
| 6 |
"""
|
| 7 |
Calls Nivra Vision Diagnosis Gradio Space using image URL
|
| 8 |
"""
|
| 9 |
try:
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
api_name="/
|
| 15 |
)
|
| 16 |
-
|
|
|
|
| 17 |
return f"""
|
| 18 |
[SYMPTOM IMAGE ANALYSIS - SUCCESS]
|
| 19 |
-
{
|
| 20 |
"""
|
| 21 |
-
|
| 22 |
except Exception as e:
|
| 23 |
return f"""
|
| 24 |
[SYMPTOM IMAGE ANALYSIS - ERROR]
|
|
|
|
| 1 |
from langchain_core.tools import tool
|
| 2 |
from gradio_client import Client
|
| 3 |
+
import json
|
| 4 |
|
| 5 |
@tool
|
| 6 |
+
def analyze_symptom_image(img_url: str) -> str:
|
| 7 |
"""
|
| 8 |
Calls Nivra Vision Diagnosis Gradio Space using image URL
|
| 9 |
"""
|
| 10 |
try:
|
| 11 |
+
result = Client.predict(
|
| 12 |
+
image_upload=None, # Explicitly None
|
| 13 |
+
image_url=img_url,
|
| 14 |
+
top_k=2,
|
| 15 |
+
api_name="/predict"
|
| 16 |
)
|
| 17 |
+
md_output = result[0]
|
| 18 |
+
result_json = json.loads(result[1])
|
| 19 |
return f"""
|
| 20 |
[SYMPTOM IMAGE ANALYSIS - SUCCESS]
|
| 21 |
+
{result_json}
|
| 22 |
"""
|
|
|
|
| 23 |
except Exception as e:
|
| 24 |
return f"""
|
| 25 |
[SYMPTOM IMAGE ANALYSIS - ERROR]
|