Update app.py
Browse filessolved problem in call_llm
app.py
CHANGED
@@ -8,7 +8,7 @@ import gradio as gr
|
|
8 |
import json
|
9 |
import hashlib
|
10 |
import numpy as np
|
11 |
-
from typing import Optional, List,
|
12 |
|
13 |
from sentence_transformers import SentenceTransformer, util, CrossEncoder
|
14 |
from langchain.llms.base import LLM
|
@@ -50,9 +50,6 @@ def call_llm(prompt: str) -> str:
|
|
50 |
"""
|
51 |
try:
|
52 |
result = llm(prompt) # Directly call the model with the prompt
|
53 |
-
# If the result is a dictionary and contains 'text', extract it.
|
54 |
-
if isinstance(result, dict) and 'text' in result:
|
55 |
-
return result['text']
|
56 |
return result if isinstance(result, str) else str(result)
|
57 |
except Exception as e:
|
58 |
logger.error(f"LLM call error: {e}")
|
@@ -179,10 +176,8 @@ sanity_checker = QuestionSanityChecker(llm)
|
|
179 |
###############################################################################
|
180 |
# 7) smolagents Integration: GROQ Model and Web Search
|
181 |
###############################################################################
|
182 |
-
# Instantiate the DuckDuckGo search tool
|
183 |
search_tool = DuckDuckGoSearchTool()
|
184 |
|
185 |
-
# Create the web agent with the search tool
|
186 |
web_agent = CodeAgent(
|
187 |
tools=[search_tool],
|
188 |
model=llm
|
|
|
8 |
import json
|
9 |
import hashlib
|
10 |
import numpy as np
|
11 |
+
from typing import Optional, List, Dict
|
12 |
|
13 |
from sentence_transformers import SentenceTransformer, util, CrossEncoder
|
14 |
from langchain.llms.base import LLM
|
|
|
50 |
"""
|
51 |
try:
|
52 |
result = llm(prompt) # Directly call the model with the prompt
|
|
|
|
|
|
|
53 |
return result if isinstance(result, str) else str(result)
|
54 |
except Exception as e:
|
55 |
logger.error(f"LLM call error: {e}")
|
|
|
176 |
###############################################################################
|
177 |
# 7) smolagents Integration: GROQ Model and Web Search
|
178 |
###############################################################################
|
|
|
179 |
search_tool = DuckDuckGoSearchTool()
|
180 |
|
|
|
181 |
web_agent = CodeAgent(
|
182 |
tools=[search_tool],
|
183 |
model=llm
|