Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,11 @@
|
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
import requests
|
5 |
-
from smolagents import DuckDuckGoSearchTool, CodeAgent, WikipediaSearchTool, LiteLLMModel, CodeAgent, tool
|
6 |
from pathlib import Path
|
7 |
import pathlib
|
8 |
import tempfile
|
9 |
import PyPDF2
|
10 |
-
from opik import track
|
11 |
import pytesseract
|
12 |
from PIL import Image
|
13 |
from smolagents.tools import PipelineTool, Tool
|
@@ -16,8 +15,6 @@ import pandas as pd
|
|
16 |
from tabulate import tabulate # pragma: no cover – fallback path
|
17 |
import re
|
18 |
import opik
|
19 |
-
import litellm
|
20 |
-
from litellm.integrations.opik.opik import OpikLogger
|
21 |
import time
|
22 |
from tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_type, before_sleep_log
|
23 |
import logging
|
@@ -183,12 +180,6 @@ def analyze_image_tool(image_path: str) -> str:
|
|
183 |
return f"Error analyzing image: {e}"
|
184 |
|
185 |
|
186 |
-
litellm.callbacks = [OpikLogger()]
|
187 |
-
llm = LiteLLMModel(
|
188 |
-
model_id="groq/llama-3.3-70b-versatile",
|
189 |
-
client=litellm,
|
190 |
-
)
|
191 |
-
|
192 |
# Define the retry decorator to handle rate limits
|
193 |
@retry(
|
194 |
retry=retry_if_exception_type(litellm.RateLimitError),
|
@@ -209,7 +200,7 @@ def call_llm_with_retry(agent, question: str) -> str:
|
|
209 |
class BasicAgent:
|
210 |
def __init__(self):
|
211 |
self.agent = CodeAgent(
|
212 |
-
model=
|
213 |
tools=[DuckDuckGoSearchTool(), WikipediaSearchTool(), ExcelToTextTool(), pdf_to_text_tool, analyze_image_tool],
|
214 |
add_base_tools=True,
|
215 |
additional_authorized_imports=['pandas', 'numpy', 'csv', 'subprocess']
|
|
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
import requests
|
5 |
+
from smolagents import DuckDuckGoSearchTool, CodeAgent, WikipediaSearchTool, LiteLLMModel, CodeAgent, tool , OpenAIServerModel
|
6 |
from pathlib import Path
|
7 |
import pathlib
|
8 |
import tempfile
|
9 |
import PyPDF2
|
|
|
10 |
import pytesseract
|
11 |
from PIL import Image
|
12 |
from smolagents.tools import PipelineTool, Tool
|
|
|
15 |
from tabulate import tabulate # pragma: no cover – fallback path
|
16 |
import re
|
17 |
import opik
|
|
|
|
|
18 |
import time
|
19 |
from tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_type, before_sleep_log
|
20 |
import logging
|
|
|
180 |
return f"Error analyzing image: {e}"
|
181 |
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
# Define the retry decorator to handle rate limits
|
184 |
@retry(
|
185 |
retry=retry_if_exception_type(litellm.RateLimitError),
|
|
|
200 |
class BasicAgent:
|
201 |
def __init__(self):
|
202 |
self.agent = CodeAgent(
|
203 |
+
model=OpenAIServerModel(model_id="gpt-4o"),
|
204 |
tools=[DuckDuckGoSearchTool(), WikipediaSearchTool(), ExcelToTextTool(), pdf_to_text_tool, analyze_image_tool],
|
205 |
add_base_tools=True,
|
206 |
additional_authorized_imports=['pandas', 'numpy', 'csv', 'subprocess']
|