Metadata-Version: 2.1
Name: function-calling-tools
Version: 0.1.1
Summary: 
Author: MarkInada
Author-email: makotoinada132@gmail.com
Requires-Python: >=3.8.1,<4.0.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: langchain (>=0.0.285,<0.0.286)
Requires-Dist: ntplib (>=0.4.0,<0.5.0)
Description-Content-Type: text/markdown

# function-calling-tools

This library provides an easy-to-use interface for function calling.

## Installation

```bash
pip install function_calling_tools
```

## Usage

see `example` for more detail.

```bash
export PIRATE_WEATHER_API_KEY=xxx
export OPENAI_API_KEY=xxx
```

```python
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](https://docs.pirateweather.net/en/latest/API/) | PIRATE_WEATHER_API_KEY                        |
| RedmineInfo             | create redmine issue                                                                    | REDMINE_URL, REDMINE_PROJECT, REDMINE_API_KEY |

