Spaces:
Sleeping
Sleeping
use prompt
Browse files- Agents/agent.py +4 -3
- Tools/tools.py +3 -1
- app.py +4 -4
Agents/agent.py
CHANGED
|
@@ -220,6 +220,7 @@ def build_graph(provider: str="groq"):
|
|
| 220 |
if provider== "groq":
|
| 221 |
print(f"Running llm groq")
|
| 222 |
llm=ChatGroq(groq_api_key=GROQ_API_KEY,model="qwen/qwen3-32b",temperature=0)
|
|
|
|
| 223 |
#webreturn = webSearch.invoke({"searchQuery":"principle of double effect Wikipedia page history St. Thomas Aquinas image added date"})
|
| 224 |
#multiple = str(multiply.invoke({"a": 2, "b": 3}))
|
| 225 |
#print(f"WebReturn : {multiple}")
|
|
@@ -241,11 +242,11 @@ def build_graph(provider: str="groq"):
|
|
| 241 |
llmWithTools = llm.bind_tools(tools)
|
| 242 |
|
| 243 |
def assistant(state: MessagesState):
|
| 244 |
-
msg = state["messages"]
|
| 245 |
#print(f"invoke llmwithtools with state message = {msg}")
|
| 246 |
-
msgbind = llmWithTools.invoke(state["messages"])
|
| 247 |
#print(f"msgBind{msgbind}")
|
| 248 |
-
return {"messages": [llmWithTools.invoke(
|
| 249 |
'''
|
| 250 |
def retriever(state: MessagesState):
|
| 251 |
similiarQuestion = vector_store.similarity_search(state["message"][0].content)
|
|
|
|
| 220 |
if provider== "groq":
|
| 221 |
print(f"Running llm groq")
|
| 222 |
llm=ChatGroq(groq_api_key=GROQ_API_KEY,model="qwen/qwen3-32b",temperature=0)
|
| 223 |
+
ChatGroq()
|
| 224 |
#webreturn = webSearch.invoke({"searchQuery":"principle of double effect Wikipedia page history St. Thomas Aquinas image added date"})
|
| 225 |
#multiple = str(multiply.invoke({"a": 2, "b": 3}))
|
| 226 |
#print(f"WebReturn : {multiple}")
|
|
|
|
| 242 |
llmWithTools = llm.bind_tools(tools)
|
| 243 |
|
| 244 |
def assistant(state: MessagesState):
|
| 245 |
+
msg = {"messages": [sysMsg] + state["messages"]}
|
| 246 |
#print(f"invoke llmwithtools with state message = {msg}")
|
| 247 |
+
#msgbind = llmWithTools.invoke(state["messages"])
|
| 248 |
#print(f"msgBind{msgbind}")
|
| 249 |
+
return {"messages": [llmWithTools.invoke(msg)]}
|
| 250 |
'''
|
| 251 |
def retriever(state: MessagesState):
|
| 252 |
similiarQuestion = vector_store.similarity_search(state["message"][0].content)
|
Tools/tools.py
CHANGED
|
@@ -7,6 +7,7 @@ from langchain_core.tools import tool
|
|
| 7 |
from langchain.tools.retriever import create_retriever_tool
|
| 8 |
from langchain_community.document_loaders import YoutubeLoader
|
| 9 |
from langchain_community.document_loaders.youtube import TranscriptFormat
|
|
|
|
| 10 |
|
| 11 |
@tool
|
| 12 |
def add(a: int, b:int) -> int:
|
|
@@ -103,7 +104,8 @@ def webSearch(searchQuery:str) -> str:
|
|
| 103 |
searchQuery: search query
|
| 104 |
"""
|
| 105 |
print("web_search: {searchQuery}")
|
| 106 |
-
search_results =
|
|
|
|
| 107 |
formatted_results = "\n\n--\n\n".join(
|
| 108 |
[
|
| 109 |
f'<Document source="{doc.metadata["source"]}" page="{doc.metadata.get("page","")}"/>\n{doc.page_content}\n</Document>'
|
|
|
|
| 7 |
from langchain.tools.retriever import create_retriever_tool
|
| 8 |
from langchain_community.document_loaders import YoutubeLoader
|
| 9 |
from langchain_community.document_loaders.youtube import TranscriptFormat
|
| 10 |
+
from langchain_tavily import TavilySearch
|
| 11 |
|
| 12 |
@tool
|
| 13 |
def add(a: int, b:int) -> int:
|
|
|
|
| 104 |
searchQuery: search query
|
| 105 |
"""
|
| 106 |
print("web_search: {searchQuery}")
|
| 107 |
+
search_results = TavilySearch(max_results=3).invoke(input=searchQuery)
|
| 108 |
+
#search_results = TavilySearchResults(max_results=2).invoke(input=searchQuery)
|
| 109 |
formatted_results = "\n\n--\n\n".join(
|
| 110 |
[
|
| 111 |
f'<Document source="{doc.metadata["source"]}" page="{doc.metadata.get("page","")}"/>\n{doc.page_content}\n</Document>'
|
app.py
CHANGED
|
@@ -41,12 +41,12 @@ class BasicAgent:
|
|
| 41 |
print("BasicAgent initialized.")
|
| 42 |
self.graph = build_graph()
|
| 43 |
def __call__(self, question: str, imageURL: str="") -> str:
|
| 44 |
-
print(f"Agent received question (first
|
| 45 |
if(imageURL.strip == ""):
|
| 46 |
messages = [HumanMessage(content=question)]
|
| 47 |
else:
|
| 48 |
formattedImageURL = gaiaValidationURL + imageURL
|
| 49 |
-
messages = [HumanMessage(content=question, additional_kwargs={imageURL:formattedImageURL })]
|
| 50 |
|
| 51 |
if(not langFuseOn):
|
| 52 |
print("no langfuse")
|
|
@@ -101,8 +101,8 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 101 |
print(f"testmode: {testMode}")
|
| 102 |
if(testMode):
|
| 103 |
# 5a test
|
| 104 |
-
question = "When was a picture of St. Thomas Aquinas first added to the wikipedia page on the principle of double effect?"
|
| 105 |
-
|
| 106 |
#graph = build_graph(provider="groq")
|
| 107 |
try:
|
| 108 |
submitted_answer = agent(question)
|
|
|
|
| 41 |
print("BasicAgent initialized.")
|
| 42 |
self.graph = build_graph()
|
| 43 |
def __call__(self, question: str, imageURL: str="") -> str:
|
| 44 |
+
print(f"Agent received question (first 100 chars): {question[:100]}...")
|
| 45 |
if(imageURL.strip == ""):
|
| 46 |
messages = [HumanMessage(content=question)]
|
| 47 |
else:
|
| 48 |
formattedImageURL = gaiaValidationURL + imageURL
|
| 49 |
+
messages = [HumanMessage(content=question, additional_kwargs={"imageURL":formattedImageURL })]
|
| 50 |
|
| 51 |
if(not langFuseOn):
|
| 52 |
print("no langfuse")
|
|
|
|
| 101 |
print(f"testmode: {testMode}")
|
| 102 |
if(testMode):
|
| 103 |
# 5a test
|
| 104 |
+
#question = "When was a picture of St. Thomas Aquinas first added to the wikipedia page on the principle of double effect?"
|
| 105 |
+
question = "Who are the pitchers with the number before and after Taishō Tamai's number as of July 2023? Give them to me in the form Pitcher Before, Pitcher After, use their last names only, in Roman characters."
|
| 106 |
#graph = build_graph(provider="groq")
|
| 107 |
try:
|
| 108 |
submitted_answer = agent(question)
|