The quickest way to make Large Language Models do things.
Project description
🐙 interfaces.to - Add a little Action to your LLM Adventure
interfaces.to (aka into
) is the quickest way to make Large Language Models do things. It's a simple, powerful and flexible way to build more useful, more engaging and more valuable applications with LLMs.
✨ Key Features
⭐️ Built-in tools for common tasks and platforms
⭐️ Start building with just 4(!) lines of code
⭐️ Developer-friendly Python library
⭐️ Extensible design for custom tools
⭐️ Simple and secure configuration
⭐️ Fully compatible with the OpenAI API SDK
⭐️ Works with gpt-4o, gpt-4o-mini and other OpenAI models
⭐️ Works with llama3.1, mistral-large and more via ollama tools
⭐️ Supports (thrives) on parallel_tool_calls
⭐️ Works with any LLM that supports the OpenAI API
⭐️ Runs on your local machine, in the cloud, or on the edge
⭐️ Open-source, MIT licensed, and community-driven
🚀 Quick Start
Installation
Install with pip:
pip install interfaces-to
or
Install with poetry:
poetry add interfaces-to
Usage
Add your favourite tools to your existing Python project with 4 lines of code:
# 1️⃣ import `into`
import interfaces_to as into
# 2️⃣ import the OpenAI client as normal
from openai import OpenAI
client = OpenAI()
# 3️⃣ add your favourite tools
tools = into.tools(['Slack','OpenAI'])
# 4️⃣ provide some input and start the loop
messages = [{"role": "user", "content": "What was the last thing said in each slack channel? Write a 5 line poem to summarise and share it in an appropriate channel"}]
while into.running(messages):
# 5️⃣ create a completion as normal, and run your tools! 🪄
completion = client.chat.completions.create(
model="gpt-4o",
messages=messages,
tools=tools,
tool_choice="auto"
)
messages = into.run(messages, completion, tools)
# 6️⃣ stand back and watch the magic happen! 🎩✨
This prints the following output:
[user] What was the last thing said in each slack channel? Write a 5 line poem to summ
arise and share it in an appropriate channel
[assistant] Calling 1 tool:
list_channels({})
[tool] Output of tool call list_channels({})
Channels: [{'id': 'C07EEUES770', 'name': 'general', 'is_channel':...
[assistant] Calling 7 tools:
read_messages({"channel": "general"})
read_messages({"channel": "hello"})
read_messages({"channel": "fun-times"})
read_messages({"channel": "poetry"})
read_messages({"channel": "jokes"})
read_messages({"channel": "welcome"})
read_messages({"channel": "random"})
[tool] Output of tool call read_messages({"channel": "random"})
Messages: [{'subtype': 'channel_join', 'user': 'U07ET3LMDB7', ...
[tool] Output of tool call read_messages({"channel": "welcome"})
Error reading messages: not_in_channel
[tool] Output of tool call read_messages({"channel": "jokes"})
Messages: [{'user': 'U07EP9STUTU', 'type': 'message', 'ts': '1722477596.990159', ...
[tool] Output of tool call read_messages({"channel": "poetry"})
Messages: [{'user': 'U07EP9STUTU', 'type': 'message', 'ts':...
[tool] Output of tool call read_messages({"channel": "fun-times"})
Messages: [{'user': 'U07EP9STUTU', 'type': 'message', 'ts': ...
[tool] Output of tool call read_messages({"channel": "hello"})
Messages: [{'subtype': 'channel_join', 'user': 'U07EP9STUTU', 'text': '<@U07EP9STUTU> has joined the channel', 'type': 'message', 'ts': '1722421262.722359'}]
[tool] Output of tool call read_messages({"channel": "general"})
Messages: [{'user': 'U07EP9STUTU', 'type': 'message', 'ts': ...
[assistant] Here is a summary poem of the last messages shared in the Slack channels:
In **#general**, they said with glee,
"Atoms make up all that we see!"
**#hello** greeted someone new,
Joining the channel, the greetings flew.
**#fun-times** loved a joke,
On atoms that can't be broke.
In the **#poetry** nook, atoms we praised,
With playful rhymes, our spirits raised.
**#jokes** was all about the spin,
Electrons in a debate always win.
And though **#welcome** remained hushed,
**#random** laughed at atoms crushed.
I'll share this poem in the **#poetry** channel.
[tool] Output of tool call send_slack_message({"channel":"poetry","message":"Here's a "...
Message sent to poetry with timestamp 1722493789.651039:
Here's a summary poem of our last messages:
In **#general**, they said with glee,
"Atoms make up all that we see!"
**#hello** greeted someone new,
Joining the channel, the greetings flew.
**#fun-times** loved a joke,
On atoms that can't be broke.
In the **#poetry** nook, atoms we praised,
With playful rhymes, our spirits raised.
**#jokes** was all about the spin,
Electrons in a debate always win.
And though **#welcome** remained hushed,
**#random** laughed at atoms crushed.
[assistant] I have shared the poem summarizing the last messages in each channel
to the **#poetry** channel.
messages
is also updated with the latest messages and retains the format needed by the OpenAI SDK, so you can continue the adventure and build more complex applications.
You can run this example in this Jupyter notebook.
Configurating tools
Using environment variables (Recommended for production)
Tools usually require a token
. Tokens can always be configured by setting the relevant environment variables. e.g. for Slack
you can set the SLACK_BOT_TOKEN
environment variable.
If you are using environment variables, you can take advantage of the into.tools
function to automatically configure your tools. This function will look for the relevant environment variables and configure the tools with default settings.
tools = into.tools(['Slack'])
Using a .env
file (Recommended for local development)
You can also configure your tools using a .env
file. This is useful if you want to keep your tokens and other settings in a single file and helpful for local development.
Simply add a .env
file in the root of your project with the following format:
SLACK_BOT_TOKEN=xoxb-12345678-xxxxxxxxxx
Setting tokens directly in code
If you prefer to set the token directly in your code or have more control over tool settings, you can do so by passing arguments to each tool. Tokens provided in code will override any environment variables.
You can optionally restrict functions
to only those which you need.
Here's an example of configuring the Slack tool:
tools = [*into.Slack(
token="xoxb-12345678-xxxxxxxxxx",
functions=["send_slack_message"]
)]
Note that each tool is preceded by an asterisk *
to unpack the tool's functions into a list, which the OpenAI API SDK expects.
📦 Available tools
into
comes with loads of pre-built tools to help you get started quickly. These tools are designed to be simple, powerful and flexible, and can be used in any combination to create a wide range of applications.
Table of available tools:
Tool | Description | Functions | Configuration |
---|---|---|---|
OpenAI | Create completions and embeddings with the OpenAI API (Yes, that means self-prompting 🔥) | create_chat_completion , create_embedding |
Uses OPENAI_API_KEY environment variable |
Slack | Send messages to Slack channels, create channels, list channels, and read messages | send_slack_message , create_channel , list_channels , read_messages |
Uses SLACK_BOT_TOKEN environment variable |
Coming soon:
- GitHub:
create_issue
: Create an issue on GitHubcreate_pull_request
: Create a pull request on GitHubcreate_gist
: Create a gist on GitHubcreate_repository
: Create a repository on GitHubcommit_to_repository
: Commit changes to a repository on GitHubget_repository
: Get a repository on GitHubsearch_repositories
: Search for repositories on GitHub
- Jira:
create_issue
: Create an issue on Jiraassign_issue
: Assign an issue on Jiratransition_issue
: Transition an issue on Jiracomment_on_issue
: Comment on an issue on Jiraget_issue
: Get an issue on Jirasearch_issues
: Search for issues on Jira
- Discord:
send_discord_message
(Send a message to a Discord channel) - Telegram:
send_telegram_message
(Send a message to a Telegram chat) - Facebook Messenger:
send_facebook_message
(Send a message to a Facebook Messenger chat) - WhatsApp:
send_whatsapp_message
(Send a message to a WhatsApp chat) - X:
post_to_x
(Post on X) - Reddit:
post_to_reddit
(Post on Reddit) - Twilio:
send_sms
(Send an SMS message) - SendGrid:
send_email
(Send an email) - Mailgun:
send_email
(Send an email) - Google Sheets:
write_to_sheet
(Write data to a Google Sheet) - Google Drive:
upload_file
(Upload a file to Google Drive) - Google Calendar:
create_event
(Create an event on Google Calendar) - Google Maps:
get_directions
(Get directions between two locations) - Google Search:
search
(Search the web) - Wikipedia:
search
(Search Wikipedia) - Weather:
get_weather
(Get the current weather)
📚 Documentation (coming soon!)
For more information, check out the detailed documentation.
💬 Community
Join the interfaces.to Slack to chat with other LLM adventurers, ask questions, and share your projects.
🤝 Contributors (coming soon!)
We welcome contributions from the community! Please see our contributing guide (coming soon) for more information.
Notable contributors and acknowledgements:
@blairhudson • 🐙
🫶 License
This project is licensed under the MIT License - see the LICENSE file for details.
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
Hashes for interfaces_to-0.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a257773ecea2d98056b8ee736d0b1d21a6ecaefb009ea59b6da2d66818cb8608 |
|
MD5 | 0e0b3506164803169bde2c2b4a6e6715 |
|
BLAKE2b-256 | 70ee43e1c65c1bc95032c70b3050188e7e088db4938e01a6bdf2199557001ac2 |