Last active
March 10, 2023 16:13
-
-
Save HelloElisaRose/d49faf7c52497c9aaa64454ee107d502 to your computer and use it in GitHub Desktop.
langchain-article-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from langchain.agents import initialize_agent, load_tools | |
from langchain.llms import OpenAI | |
from langchain_prefect.plugins import RecordLLMCalls | |
from prefect import flow | |
llm = OpenAI(temperature=0) | |
tools = load_tools(["llm-math"], llm=llm) | |
agent = initialize_agent(tools, llm) | |
@flow | |
def my_flow(): | |
"""Flow wrapping any LLM calls made by the agent.""" | |
return agent.run( | |
"How old is the current Dalai Lama? " | |
"What is his age divided by 2 (rounded to the nearest integer)?" | |
) | |
with RecordLLMCalls(tags={"agent"}): | |
result = my_flow() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment