No project description provided
Project description
function-calling-tools
This library provides an easy-to-use interface for function calling.
Installation
pip install function_calling_tools
Usage
see example
for more detail.
export PIRATE_WEATHER_API_KEY=xxx
export OPENAI_API_KEY=xxx
import os
import openai
from langchain.memory import ConversationBufferMemory
from langchain.prompts import MessagesPlaceholder
from langchain.chat_models import ChatOpenAI
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from function_calling_tools.ntp import TimeZoneDatetimeFetcher
from function_calling_tools.pirateweather import WeatherFetcher
tools = [
TimeZoneDatetimeFetcher(),
WeatherFetcher(),
]
memory = ConversationBufferMemory(memory_key="memory", return_messages=True)
agent_kwargs = {
"extra_prompt_messages": [MessagesPlaceholder(variable_name="memory")],
}
prompt = """
Don't make assumptions about what values to plug into functions. Ask for clarification if a user request is ambiguous.
"""
memory.save_context({"input": prompt}, {"output": "I got it!"})
openai.api_key = os.environ["OPENAI_API_KEY"]
llm = ChatOpenAI(model_name="gpt-3.5-turbo")
agent = initialize_agent(
tools,
llm,
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True,
agent_kwargs=agent_kwargs,
memory=memory,
)
agent.run(input="What is the weather like in Tokyo today?")
Module Name | Description | Additional Parameters |
---|---|---|
TimeZoneDatetimeFetcher | fetch current datetime in timezone | - |
WeatherFetcher | fetch weather info using piratewhether | PIRATE_WEATHER_API_KEY |
RedmineInfo | create redmine issue | REDMINE_URL, REDMINE_PROJECT, REDMINE_API_KEY |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for function_calling_tools-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1ab284b062edabca6574815bdde7ac55c19bc84f2592be12b104b85185885bd |
|
MD5 | 45ce7e641353fcf8a288e93742677232 |
|
BLAKE2b-256 | 76f4993dd0038b9eac7a83d8e5c6566611b5a2ea146a243c0d9f3cf91e7f750d |
Close
Hashes for function_calling_tools-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaa122534bf16353c7d57dd0c219d66a4d99b357ebb45856db8f902fef5274f3 |
|
MD5 | 8ae2c7a78ba46964912cb1cab79414ba |
|
BLAKE2b-256 | b1ce4bc15a71dd46dfd88fec3b1d4df133c7cb508ece29cb9217a833cd488b10 |