Romain Fayoux
commited on
Commit
·
7bac906
1
Parent(s):
371e0b8
Building a langchain agent
Browse files- langchain_agent.py +18 -0
- requirements.txt +4 -0
langchain_agent.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain.agents import create_agent
|
| 2 |
+
from langgraph.checkpoint.memory import InMemorySaver
|
| 3 |
+
from langchain_community.tools import DuckDuckGoSearchRun
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
system_prompt = """finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
|
| 7 |
+
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
|
| 8 |
+
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.
|
| 9 |
+
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.
|
| 10 |
+
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."""
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
agent = create_agent(
|
| 14 |
+
model="google-genai:gemini-2.5-flash",
|
| 15 |
+
tools=[DuckDuckGoSearchRun()],
|
| 16 |
+
system_prompt=system_prompt,
|
| 17 |
+
checkpointer=InMemorySaver(),
|
| 18 |
+
)
|
requirements.txt
CHANGED
|
@@ -12,3 +12,7 @@ chess
|
|
| 12 |
pandas
|
| 13 |
ipykernel
|
| 14 |
arize-phoenix
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
pandas
|
| 13 |
ipykernel
|
| 14 |
arize-phoenix
|
| 15 |
+
langchain
|
| 16 |
+
langchain-google-genai
|
| 17 |
+
duckduckgo-search
|
| 18 |
+
langchain-community
|