Spaces:
Configuration error
Configuration error
Use Groq
Browse files- agent.py +5 -12
- requirements.txt +1 -0
agent.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
|
|
|
|
|
| 1 |
# --- Langchain / Langraph ---
|
| 2 |
from langchain_community.tools.tavily_search import TavilySearchResults
|
| 3 |
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
|
| 4 |
from langchain_core.runnables import RunnableLambda
|
| 5 |
from langchain_core.tools import tool
|
| 6 |
from langchain_experimental.tools.python.tool import PythonREPLTool
|
|
|
|
| 7 |
from langchain_huggingface import (
|
| 8 |
ChatHuggingFace,
|
| 9 |
HuggingFaceEmbeddings,
|
|
@@ -67,22 +70,12 @@ Your response must always begin with: FINAL ANSWER:
|
|
| 67 |
)
|
| 68 |
|
| 69 |
|
| 70 |
-
def build_agent_graph(provider: str = "
|
| 71 |
# Define toolset
|
| 72 |
tools = [search_web_sources, run_python_code]
|
| 73 |
|
| 74 |
# Instantiate LLM
|
| 75 |
-
llm =
|
| 76 |
-
llm=HuggingFaceEndpoint(
|
| 77 |
-
repo_id="TinyLlama/TinyLlama-1.1B-Chat-v1.0",
|
| 78 |
-
task="text-generation",
|
| 79 |
-
max_new_tokens=1024,
|
| 80 |
-
do_sample=False,
|
| 81 |
-
repetition_penalty=1.03,
|
| 82 |
-
temperature=0,
|
| 83 |
-
),
|
| 84 |
-
verbose=True,
|
| 85 |
-
)
|
| 86 |
|
| 87 |
# Bind tools to the LLM
|
| 88 |
llm_with_tools = llm.bind_tools(tools)
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
# --- Langchain / Langraph ---
|
| 4 |
from langchain_community.tools.tavily_search import TavilySearchResults
|
| 5 |
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
|
| 6 |
from langchain_core.runnables import RunnableLambda
|
| 7 |
from langchain_core.tools import tool
|
| 8 |
from langchain_experimental.tools.python.tool import PythonREPLTool
|
| 9 |
+
from langchain_groq import ChatGroq
|
| 10 |
from langchain_huggingface import (
|
| 11 |
ChatHuggingFace,
|
| 12 |
HuggingFaceEmbeddings,
|
|
|
|
| 70 |
)
|
| 71 |
|
| 72 |
|
| 73 |
+
def build_agent_graph(provider: str = "groq"):
|
| 74 |
# Define toolset
|
| 75 |
tools = [search_web_sources, run_python_code]
|
| 76 |
|
| 77 |
# Instantiate LLM
|
| 78 |
+
llm = ChatGroq(model="qwen-qwq-32b", temperature=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
# Bind tools to the LLM
|
| 81 |
llm_with_tools = llm.bind_tools(tools)
|
requirements.txt
CHANGED
|
@@ -4,6 +4,7 @@ langchain
|
|
| 4 |
langchain-core
|
| 5 |
langchain-community
|
| 6 |
langchain_huggingface
|
|
|
|
| 7 |
langchain-experimental
|
| 8 |
langchain-tavily
|
| 9 |
langgraph
|
|
|
|
| 4 |
langchain-core
|
| 5 |
langchain-community
|
| 6 |
langchain_huggingface
|
| 7 |
+
langchain-groq
|
| 8 |
langchain-experimental
|
| 9 |
langchain-tavily
|
| 10 |
langgraph
|