Spaces:
Sleeping
Sleeping
Upload agent.py
Browse files
agent.py
CHANGED
|
@@ -9,6 +9,8 @@ from langchain_community.document_loaders import WikipediaLoader
|
|
| 9 |
from langchain_core.messages import HumanMessage
|
| 10 |
from langchain_core.tools import tool
|
| 11 |
from langchain_mistralai import ChatMistralAI
|
|
|
|
|
|
|
| 12 |
|
| 13 |
load_dotenv()
|
| 14 |
|
|
@@ -107,11 +109,13 @@ tools = [
|
|
| 107 |
def build_graph():
|
| 108 |
|
| 109 |
|
| 110 |
-
llm = ChatMistralAI(
|
| 111 |
model="magistral-small-2506",
|
| 112 |
temperature=0,
|
| 113 |
max_retries=2,
|
| 114 |
-
)
|
|
|
|
|
|
|
| 115 |
|
| 116 |
llm_with_tools = llm.bind_tools(tools)
|
| 117 |
|
|
@@ -138,7 +142,7 @@ def build_graph():
|
|
| 138 |
if __name__=="__main__":
|
| 139 |
#system_prompt = "You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."
|
| 140 |
system_prompt = "You are a general AI assistant. I will ask you a question. Give your answer with the following template: only show your final answer. Your final answer should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."
|
| 141 |
-
question = "when was
|
| 142 |
question = f"{system_prompt} \
|
| 143 |
The question: \
|
| 144 |
{question} \
|
|
|
|
| 9 |
from langchain_core.messages import HumanMessage
|
| 10 |
from langchain_core.tools import tool
|
| 11 |
from langchain_mistralai import ChatMistralAI
|
| 12 |
+
from langchain_groq import ChatGroq
|
| 13 |
+
|
| 14 |
|
| 15 |
load_dotenv()
|
| 16 |
|
|
|
|
| 109 |
def build_graph():
|
| 110 |
|
| 111 |
|
| 112 |
+
'''llm = ChatMistralAI(
|
| 113 |
model="magistral-small-2506",
|
| 114 |
temperature=0,
|
| 115 |
max_retries=2,
|
| 116 |
+
)'''
|
| 117 |
+
|
| 118 |
+
llm = ChatGroq(model="qwen-qwq-32b", temperature=0) # optional : qwen-qwq-32b gemma2-9b-it
|
| 119 |
|
| 120 |
llm_with_tools = llm.bind_tools(tools)
|
| 121 |
|
|
|
|
| 142 |
if __name__=="__main__":
|
| 143 |
#system_prompt = "You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."
|
| 144 |
system_prompt = "You are a general AI assistant. I will ask you a question. Give your answer with the following template: only show your final answer. Your final answer should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."
|
| 145 |
+
question = "when was the Eiffel tower built?"
|
| 146 |
question = f"{system_prompt} \
|
| 147 |
The question: \
|
| 148 |
{question} \
|