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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file function_calling_tools-0.1.1.tar.gz.

File metadata

  • Download URL: function_calling_tools-0.1.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.1 Darwin/20.6.0

File hashes

Hashes for function_calling_tools-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f1ab284b062edabca6574815bdde7ac55c19bc84f2592be12b104b85185885bd
MD5 45ce7e641353fcf8a288e93742677232
BLAKE2b-256 76f4993dd0038b9eac7a83d8e5c6566611b5a2ea146a243c0d9f3cf91e7f750d

See more details on using hashes here.

File details

Details for the file function_calling_tools-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for function_calling_tools-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eaa122534bf16353c7d57dd0c219d66a4d99b357ebb45856db8f902fef5274f3
MD5 8ae2c7a78ba46964912cb1cab79414ba
BLAKE2b-256 b1ce4bc15a71dd46dfd88fec3b1d4df133c7cb508ece29cb9217a833cd488b10

See more details on using hashes here.

Supported by

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