update model
Browse files- __pycache__/agent.cpython-39.pyc +0 -0
- agent.py +36 -22
- app.py +2 -2
- requirements.txt +3 -1
__pycache__/agent.cpython-39.pyc
CHANGED
|
Binary files a/__pycache__/agent.cpython-39.pyc and b/__pycache__/agent.cpython-39.pyc differ
|
|
|
agent.py
CHANGED
|
@@ -7,22 +7,31 @@ from langchain_core.messages import HumanMessage, AIMessage, SystemMessage
|
|
| 7 |
from langchain_core.tools import tool
|
| 8 |
from ddgs import DDGS
|
| 9 |
from dotenv import load_dotenv
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
load_dotenv()
|
| 13 |
|
| 14 |
# Base Hugging Face LLM used by the chat wrapper
|
| 15 |
-
base_llm = HuggingFaceEndpoint(
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
)
|
| 22 |
|
| 23 |
-
# Chat model that works with LangGraph
|
| 24 |
-
model = ChatHuggingFace(llm=base_llm)
|
| 25 |
-
|
| 26 |
@tool
|
| 27 |
def web_search(keywords: str, max_results:int = 5) -> str:
|
| 28 |
"""
|
|
@@ -49,21 +58,26 @@ def web_search(keywords: str, max_results:int = 5) -> str:
|
|
| 49 |
output += f"Results: {result['title']}\n{result['body']}\n{result['href']}\n\n"
|
| 50 |
return(output)
|
| 51 |
|
| 52 |
-
@tool
|
| 53 |
-
def get_image_file(task_id):
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
|
| 69 |
class AgentState(TypedDict):
|
|
|
|
| 7 |
from langchain_core.tools import tool
|
| 8 |
from ddgs import DDGS
|
| 9 |
from dotenv import load_dotenv
|
| 10 |
+
from groq import Groq
|
| 11 |
+
from langchain_groq import ChatGroq
|
| 12 |
+
from langchain_community.document_loaders.image import UnstructuredImageLoader
|
| 13 |
|
| 14 |
|
| 15 |
load_dotenv()
|
| 16 |
|
| 17 |
# Base Hugging Face LLM used by the chat wrapper
|
| 18 |
+
# base_llm = HuggingFaceEndpoint(
|
| 19 |
+
# repo_id="openai/gpt-oss-20b:hyperbolic",
|
| 20 |
+
# # deepseek-ai/DeepSeek-OCR:novita
|
| 21 |
+
# task="text-generation",
|
| 22 |
+
# temperature=0.0,
|
| 23 |
+
# huggingfacehub_api_token=os.getenv("HUGGINGFACEHUB_API_TOKEN"),
|
| 24 |
+
# )
|
| 25 |
+
|
| 26 |
+
model = ChatGroq(
|
| 27 |
+
model="meta-llama/llama-4-scout-17b-16e-instruct",
|
| 28 |
+
temperature=0,
|
| 29 |
+
max_tokens=None,
|
| 30 |
+
timeout=None,
|
| 31 |
+
max_retries=2,
|
| 32 |
+
# other params...
|
| 33 |
)
|
| 34 |
|
|
|
|
|
|
|
|
|
|
| 35 |
@tool
|
| 36 |
def web_search(keywords: str, max_results:int = 5) -> str:
|
| 37 |
"""
|
|
|
|
| 58 |
output += f"Results: {result['title']}\n{result['body']}\n{result['href']}\n\n"
|
| 59 |
return(output)
|
| 60 |
|
| 61 |
+
# @tool
|
| 62 |
+
# def get_image_file(task_id):
|
| 63 |
+
# """
|
| 64 |
+
# Get the image file from the question
|
| 65 |
+
# Use cases:
|
| 66 |
+
# - Extract Image from the question
|
| 67 |
|
| 68 |
+
# Args:
|
| 69 |
+
# task_id: the task_id of the question
|
| 70 |
|
| 71 |
+
# Returns:
|
| 72 |
+
# Image file result
|
| 73 |
+
# """
|
| 74 |
+
|
| 75 |
+
# loader = UnstructuredImageLoader("./example_data/layout-parser-paper-screenshot.png")
|
| 76 |
+
|
| 77 |
+
# data = loader.load()
|
| 78 |
+
|
| 79 |
+
# data[0]
|
| 80 |
+
# return ''
|
| 81 |
|
| 82 |
|
| 83 |
class AgentState(TypedDict):
|
app.py
CHANGED
|
@@ -80,8 +80,8 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 80 |
results_log = []
|
| 81 |
answers_payload = []
|
| 82 |
# print(f"Running agent on {len(questions_data)} questions...")
|
| 83 |
-
print(f"Running agent on {len(questions_data
|
| 84 |
-
for item in questions_data
|
| 85 |
task_id = item.get("task_id")
|
| 86 |
question_text = item.get("question")
|
| 87 |
if not task_id or question_text is None:
|
|
|
|
| 80 |
results_log = []
|
| 81 |
answers_payload = []
|
| 82 |
# print(f"Running agent on {len(questions_data)} questions...")
|
| 83 |
+
print(f"Running agent on {len(questions_data)} questions temporarily...")
|
| 84 |
+
for item in questions_data:
|
| 85 |
task_id = item.get("task_id")
|
| 86 |
question_text = item.get("question")
|
| 87 |
if not task_id or question_text is None:
|
requirements.txt
CHANGED
|
@@ -18,4 +18,6 @@ pgvector
|
|
| 18 |
python-dotenv
|
| 19 |
pandas
|
| 20 |
numpy
|
| 21 |
-
ddgs
|
|
|
|
|
|
|
|
|
| 18 |
python-dotenv
|
| 19 |
pandas
|
| 20 |
numpy
|
| 21 |
+
ddgs
|
| 22 |
+
groq
|
| 23 |
+
unstructured[all-docs]
|