ayush1603 commited on
Commit
452d386
Β·
verified Β·
1 Parent(s): 9e49c5e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -14,26 +14,25 @@ import gradio as gr # Gradio Blocks UI
14
  import litellm # LiteLLM client for Groq
15
  from litellm.integrations.opik.opik import OpikLogger
16
 
17
- from smolagents import tool, LiteLLMModel, CodeAgent
18
- from smolagents.tools import DuckDuckGoSearchTool, WikipediaSearchTool, SpeechToTextTool ,PythonInterpreterTool
19
 
20
  # ── 1) Read API keys from HF Spaces Secrets/Variables ───────────────────────
21
- GROQ_API_KEY = os.getenv("Grok_api") # set as Secret in your Space citeξˆ‚turn1search0
22
- OPIK_API_KEY = os.getenv("OPIK_API_KEY") # set as Secret in your Space citeξˆ‚turn1search1
23
- OPIK_WORKSPACE = os.getenv("OPIK_WORKSPACE") # set as Variable in your Space citeξˆ‚turn1search1
24
 
25
  # ── 2) Configure litellm & OpikLogger ───────────────────────────────────────
26
- os.environ["GROQ_API_KEY"] = GROQ_API_KEY # must be set before any litellm calls citeξˆ‚turn1search0
27
- os.environ["OPIK_API_KEY"] = OPIK_API_KEY # must be set before OpikLogger init citeξˆ‚turn1search1
28
  os.environ["OPIK_WORKSPACE"] = OPIK_WORKSPACE
29
 
30
- litellm.callbacks = [OpikLogger()] # attach Opik tracing after env vars exist citeξˆ‚turn1search1
31
 
32
  # ── 3) Create a Groq-backed LiteLLMModel ───────────────────────────────────
33
  llm = LiteLLMModel(
34
  model_id="groq/llama-3.3-70b-versatile",
35
  client=litellm
36
- ) # Groq via litellm uses GROQ_API_KEY env var citeξˆ‚turn1search0
37
 
38
  # ── 4) Define function-based tools with @tool ─────────────────────────────
39
  @tool
 
14
  import litellm # LiteLLM client for Groq
15
  from litellm.integrations.opik.opik import OpikLogger
16
 
17
+ from smolagents import tool, LiteLLMModel, CodeAgent , DuckDuckGoSearchTool, WikipediaSearchTool, SpeechToTextTool ,PythonInterpreterTool
 
18
 
19
  # ── 1) Read API keys from HF Spaces Secrets/Variables ───────────────────────
20
+ GROQ_API_KEY = os.getenv("Grok_api")
21
+ OPIK_API_KEY = os.getenv("OPIK_API_KEY")
22
+ OPIK_WORKSPACE = os.getenv("OPIK_WORKSPACE")
23
 
24
  # ── 2) Configure litellm & OpikLogger ───────────────────────────────────────
25
+ os.environ["GROQ_API_KEY"] = GROQ_API_KEY
26
+ os.environ["OPIK_API_KEY"] = OPIK_API_KEY
27
  os.environ["OPIK_WORKSPACE"] = OPIK_WORKSPACE
28
 
29
+ litellm.callbacks = [OpikLogger()]
30
 
31
  # ── 3) Create a Groq-backed LiteLLMModel ───────────────────────────────────
32
  llm = LiteLLMModel(
33
  model_id="groq/llama-3.3-70b-versatile",
34
  client=litellm
35
+ )
36
 
37
  # ── 4) Define function-based tools with @tool ─────────────────────────────
38
  @tool