Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

function_calling_tools-0.1.1.tar.gz (7.1 kB view hashes)

Uploaded Source

Built Distribution

function_calling_tools-0.1.1-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page