Skip to content

Instantly share code, notes, and snippets.

@HelloElisaRose
Last active March 10, 2023 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HelloElisaRose/d49faf7c52497c9aaa64454ee107d502 to your computer and use it in GitHub Desktop.
Save HelloElisaRose/d49faf7c52497c9aaa64454ee107d502 to your computer and use it in GitHub Desktop.
langchain-article-1
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