Skip to content

Instantly share code, notes, and snippets.

@Jensssen
Created May 19, 2023 11:26
Show Gist options
  • Save Jensssen/e72a5e5ec93dca7aa9f2a10bb5ee499b to your computer and use it in GitHub Desktop.
Save Jensssen/e72a5e5ec93dca7aa9f2a10bb5ee499b to your computer and use it in GitHub Desktop.
How to define tools in LangChain.
from langchain.agents import Tool
tools = [
Tool(
name="play_action",
func=play_a_song,
description="Useful when you want to play one song via the spotify api. "
"Try to find a single song that fits best to the prompt of the user! "
"This song should be the input to this tool in form of a comma "
"separated list of strings of length two! Representing the title and the "
"interpreter or album you want to play. For example, `I Was Made For "
"Loving You,KISS` would be the input if you wanted to play a specific "
"song. Never send multiple songs, only a single one is allowed!"
),
Tool(
name="search",
func=search_on_internet,
description="Useful if you do not know an answer to the users question. "
"Then you can use this tool to search for the answer on the Internet. "
"The tool requires a search query string as input. Formulate a search "
"query ALWAYS as a question!"
),
Tool(
name="album_info",
func=get_album_info,
description="Useful if you want to know which songs are on a particular music album. "
"The input to this tool should be the album name and the name of the band."
)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment