Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0xry4n/airistotle
Airistotle is a basic implementation of the OpenAI Assistants API for making simple programmatic AI assistants.
https://github.com/0xry4n/airistotle
ai-chat assistants-api chatbot gpt openai slack-bot
Last synced: 7 days ago
JSON representation
Airistotle is a basic implementation of the OpenAI Assistants API for making simple programmatic AI assistants.
- Host: GitHub
- URL: https://github.com/0xry4n/airistotle
- Owner: 0xRy4n
- License: mit
- Created: 2023-12-01T23:07:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-12T02:06:56.000Z (10 months ago)
- Last Synced: 2024-11-11T15:17:07.701Z (2 months ago)
- Topics: ai-chat, assistants-api, chatbot, gpt, openai, slack-bot
- Language: Python
- Homepage:
- Size: 32.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Airistotle
Basic implementation of the assistants API. Supports easy extensibility with function calls.
See https://platform.openai.com/assistants to setup an assistant.
# Usage
First, copy the `.env.template` to `.env` and set any necessary variables. All `Airistotle` variables are required.
Depending on what interfaces you use and what plugins you have enabled, you may need to set additional environment variables.```python
from airistotle import Assistant
from airsitotle import settingsassistant = Assistant(
openai_api_key=settings.OPENAI_API_KEY,
assistant_id=settings.ASSISTANT_ID
)assistant.send_message("What is 2+2?")
response = assistant.get_response()print(response)
>>> 2+2 equals 4.
```For the CLI interface, simply import it from an interactive shell:
```python
from airistotle.interfaces import cli
```## Plugins
Plugins are defined in `airistotle.plugins`.
Plugins can easily be added by extending the `BasePlugin` class in `airistotle.plugins.base`. The only expectation is that all plugin classes will
implement a `run()` method will return a string (the result of the function call). Converting a more complex data structure like a dict or list into a string will work fine.It is also expected your Plugin Class will have a class attribute called `name` which corresponds to the function name you defined in your assistants function definition.
The arguments of your `run` method do not matter as long as they match the parameters you specified in your assistant's function definition.
Here is an example of the function definition for the `WebSearch` plugin:
```json
{
"name": "web_search",
"description": "Perform a web search and retrieve the contents from the top results. Use this when ever you are unsure of an answer and need more information. Use it to supplement your own knowledge, not replace it.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The query you want to search for."
}
},
"required": [
"query"
]
}
}
```When called, the assistant class will unpack the keyword argument list generated by the OpenAI Assistant and pass it to the run argument. In the above example, it's expected that the run function would have a single parameter `query` which would except a `str`.
### Enabling Plugins
You can enable plugins in the `settings.py` file.
```python
from .plugins import YourPlugin
AVAILABLE_PLUGINS = {
YourPlugin.name:YourPlugin(),
}```
As long as there is a corresponding function definition in your assistant (see https://platform.openai.com/assistants), this will allow the Assistant class to process the action when the function call is requested. Keep in mind, it's up to the discretion of the OpenAI Assistant to determine when to call functions, and this is influenced both by system prompt and by function description.
## Interfaces
Some pre-written interfaces, such as a Slack Interface, may be configured in the `airistotle.interfaces` directory.
#### Notes
Airistotle uses Haystack for a basic web_search function, which is incredibly overkill. You can remove this function if you'd like to avoid the Haystack dependency. Alternatively, you can use Haystack for additional extensibility via plugins.