imeesam commited on
Commit
122fef6
Β·
verified Β·
1 Parent(s): 7c4b57a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -15,10 +15,16 @@ os.environ["GROQ_API_KEY"] = os.getenv("GROQ_API_KEY")
15
 
16
  # ─── LLM ─────────────────────────────────
17
  llm = ChatGroq(
18
- model="llama-3.1-8b-instant")
 
 
 
19
 
20
  # ─── Tools ───────────────────────────────
21
- search_tool = DuckDuckGoSearchRun()
 
 
 
22
 
23
  @tool
24
  def calculator(first_num: float, second_num: float, operation: str) -> dict:
@@ -35,7 +41,7 @@ def get_stock_price(symbol: str) -> dict:
35
  url = f"https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol={symbol}&apikey={os.getenv('STOCKS_API_KEY')}"
36
  return requests.get(url).json()
37
 
38
- tools = [search_tool, calculator, get_stock_price]
39
  llm_with_tools = llm.bind_tools(tools)
40
 
41
  # ─── State ───────────────────────────────
@@ -79,6 +85,7 @@ demo = gr.ChatInterface(
79
  "What's happening in AI news today?",
80
  "Calculate 128 multiplied by 37",
81
  ],
 
82
  )
83
 
84
  if __name__ == "__main__":
 
15
 
16
  # ─── LLM ─────────────────────────────────
17
  llm = ChatGroq(
18
+ model="llama-3.1-8b-instant",
19
+ max_tokens=300,
20
+ temperature=0
21
+ )
22
 
23
  # ─── Tools ───────────────────────────────
24
+ @tool
25
+ def search(query: str) -> str:
26
+ """Search the web for current information."""
27
+ return DuckDuckGoSearchRun().run(query)
28
 
29
  @tool
30
  def calculator(first_num: float, second_num: float, operation: str) -> dict:
 
41
  url = f"https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol={symbol}&apikey={os.getenv('STOCKS_API_KEY')}"
42
  return requests.get(url).json()
43
 
44
+ tools = [search, calculator, get_stock_price]
45
  llm_with_tools = llm.bind_tools(tools)
46
 
47
  # ─── State ───────────────────────────────
 
85
  "What's happening in AI news today?",
86
  "Calculate 128 multiplied by 37",
87
  ],
88
+ cache_examples=False # πŸ”₯ ADD THIS
89
  )
90
 
91
  if __name__ == "__main__":