Spaces:
Sleeping
Sleeping
Update final_agent.py
Browse files- final_agent.py +12 -5
final_agent.py
CHANGED
|
@@ -20,6 +20,7 @@ from langgraph.graph.message import add_messages
|
|
| 20 |
from langgraph.prebuilt import ToolNode, tools_condition
|
| 21 |
from langchain_core.messages import BaseMessage, HumanMessage, AIMessage, ToolMessage
|
| 22 |
from langchain_core.tools import tool
|
|
|
|
| 23 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 24 |
from langchain_community.tools.tavily_search import TavilySearchResults
|
| 25 |
|
|
@@ -29,6 +30,7 @@ from langchain_community.tools.tavily_search import TavilySearchResults
|
|
| 29 |
load_dotenv()
|
| 30 |
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
| 31 |
tavily_api_key = os.getenv("TAVILY_API_KEY")
|
|
|
|
| 32 |
|
| 33 |
# --- Optional: Tesseract Path ---
|
| 34 |
# If Tesseract OCR is not in your system's PATH environment variable,
|
|
@@ -47,12 +49,17 @@ if not tavily_api_key:
|
|
| 47 |
|
| 48 |
# --- Initialize LLM ---
|
| 49 |
# Using the model specified in the user's code block
|
| 50 |
-
llm = ChatGoogleGenerativeAI(
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
)
|
| 55 |
-
print(f"LLM Initialized: {llm.model}")
|
| 56 |
|
| 57 |
# ==============================================================================
|
| 58 |
# State Definition
|
|
|
|
| 20 |
from langgraph.prebuilt import ToolNode, tools_condition
|
| 21 |
from langchain_core.messages import BaseMessage, HumanMessage, AIMessage, ToolMessage
|
| 22 |
from langchain_core.tools import tool
|
| 23 |
+
from langchain_groq import ChatGroq
|
| 24 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 25 |
from langchain_community.tools.tavily_search import TavilySearchResults
|
| 26 |
|
|
|
|
| 30 |
load_dotenv()
|
| 31 |
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
| 32 |
tavily_api_key = os.getenv("TAVILY_API_KEY")
|
| 33 |
+
groq_api_key = os,getenv("GROQ_API_KEY")
|
| 34 |
|
| 35 |
# --- Optional: Tesseract Path ---
|
| 36 |
# If Tesseract OCR is not in your system's PATH environment variable,
|
|
|
|
| 49 |
|
| 50 |
# --- Initialize LLM ---
|
| 51 |
# Using the model specified in the user's code block
|
| 52 |
+
# llm = ChatGoogleGenerativeAI(
|
| 53 |
+
# model="gemini-2.0-flash-lite", # As per user's last provided code
|
| 54 |
+
# google_api_key=gemini_api_key,
|
| 55 |
+
# temperature=0.1 # Low temperature for factual tasks
|
| 56 |
+
# )
|
| 57 |
+
llm = ChatGroq(
|
| 58 |
+
model="gemma2-9b-it",
|
| 59 |
+
api_key=groq_api_key,
|
| 60 |
+
temperature = 0.1
|
| 61 |
)
|
| 62 |
+
# print(f"LLM Initialized: {llm.model}")
|
| 63 |
|
| 64 |
# ==============================================================================
|
| 65 |
# State Definition
|