Skip to content

Instantly share code, notes, and snippets.

@hwchase17
Created March 27, 2023 01:56
Show Gist options
  • Star 43 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save hwchase17/554e70983e9a4005d20c076f3581fd2e to your computer and use it in GitHub Desktop.
Save hwchase17/554e70983e9a4005d20c076f3581fd2e to your computer and use it in GitHub Desktop.
from langchain.llms import Anthropic
from langchain.agents import load_tools, initialize_agent
from langchain.tools import AIPluginTool
PREFIX = """\n\nHuman: Answer the following questions as best you can. You have access to the following tools:"""
SUFFIX = """Begin!
Question: {input}
\n\nAssistant:
Thought:{agent_scratchpad}"""
tool = AIPluginTool.from_plugin_url("https://www.klarna.com/.well-known/ai-plugin.json")
llm = Anthropic(temperature=0)
tools = load_tools(["requests"] )
tools += [tool]
agent_kwargs = {"prefix": PREFIX, "suffix": SUFFIX}
agent_chain = initialize_agent(
tools, llm, agent="zero-shot-react-description", verbose=True, agent_kwargs=agent_kwargs
)
agent_chain.run("what t shirts are available in klarna?")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment