Skip to main content

No project description provided

Project description

LaunchKit

logo

Discord PyPI - Downloads PyPI - License

LaunchKit is an open-source library that enables developers to create and manage Python-based tools which enhance GPT chatbots' capabilities. It turns your Python code into a format that large language models (LLMs) like OpenAI's GPT can understand and use, thanks to the generation of JSON schemas driven by your code's type annotations.

Using Pydantic, LaunchKit reads your code's structure and details, ensuring that bots can interact with your tools correctly. This process provides clear, enforceable contracts between your functions and chatbots, making your bots more robust and easier to maintain.

With Launchkit, you can:

  1. Create Python-based tools that your bot can use.
  2. Talk with your bot and test functions locally.
  3. Deploy the upgraded bot to channels like Discord, Slack, and Telegram. (via MissionControl)

Toy Example

from launchkit import LaunchKit

def add(a: int, b: int):
    """Adds two numbers together."""
    return a + b

# async functions are also supported
async def fetch_today_weather():
    """Gets today's weather."""
    await some_async_function()
    return {
        "temperature": 20,
        "humidity": 50
    }

tools = LaunchKit([add, fetch_today_weather])

tools.openai_tools() # list of tools in OpenAI format - ready to be sent to the API.

Talk with your bot locally in the terminal:

launchkit module_name:tools

Getting started

  1. Install PDM

  2. Create a new project

mkdir my_project
cd my_project
pdm init --copier gh:missioncontrolai/template
pdm install
  1. Test it out
pdm test # run tests
pdm dev # talk with your bot
  1. Deploy it (with MissionControl)
git init
git add .
git commit -m "Initial commit"

First Steps

Create functions

def add(a: int, b: int): # use a descriptive name and type annotations
    """Adds two numbers together.""" # add a docstring
    return a + b

[!NOTE]

  • The function's name will be used as the tool's name. The docstring will be used as the tool's description.
  • Use type annotations(More on types) to help the bot understand what kind of data to send to your function.

Async functions are also supported:

async def fetch_today_weather():
    """Gets today's weather."""
    await some_async_function()
    return {
        "temperature": 20,
        "humidity": 50
    }

[!NOTE]

  • Return type should be serializable to JSON.
  • When returning a dictionary, make sure that the fiels names are descriptive. The bot will use them to generate better summaries to function execution results.

Exposing your functions to the bot

from launchkit import LaunchKit

tools = LaunchKit([add, fetch_today_weather])

Testing

Talk with your bot locally in the terminal:

launchkit module_name:tools

Write tests for your functions:

def test_add():
    assert add(1, 2) == 3

Summary

  • Use descriptive names
  • Add docstrings
  • Use type annotations
  • Return type should be serializable to JSON
  • Return dictionaries with descriptive field names

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

launchkit-0.1.6.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

launchkit-0.1.6-py3-none-any.whl (5.6 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