Skip to content

XO30/gpt-assistants

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn

GPT Assistants Python API

This is a Python API for the new GPT Assistants API from OpenAI. It is designed to help you get started with the API and simplify the process of building your own GPT Assistant.
Explore the docs »

Report Bug Request Feature

About The Project

GPT Assistants Python API is a Python wrapper for the new GPT Assistants API from OpenAI. It is designed to help you get started with bulding your own GPT Assistant and. Assistants can be simply created and modified with the help of the API. Furthermore, the API provides a simple way to create threads, messages and runs.

Usage

the following examples show the basic usage of the API. There are way more functions available. For more information see the code. in the near I will update the documentation and add more examples.

API Key

To use the API you need an API key from OpenAI. You can get one here. Furthermore, you need to install set your API key as an environment variable.

API_KEY = 'api-key'
import os
os.environ['OPENAI_API_KEY'] = API_KEY

First you need to import some functions from the api

from gpt_assistants_api.assistant import list_assistants, retrieve_assistant, delete_assistant, modify_assistant,
    create_assistant
from gpt_assistants_api.thread import create_thread, retrieve_thread, delete_thread, modify_thread
from gpt_assistants_api.utils import Tools

Assistant

With the api you can easily create new assistants and modify them.

Let's create a new assistant. The only required parameter is the model. The other parameters are optional. See the documentation to see what parameters are available.

assistant = create_assistant(
    model="gpt-4",
    name="my-assistant",
    description="my first assistant",
    instructions="be a friendly assistant"
)

assistant.info()

list_assistants()

Thread

Let's now create a new thread.

thread = create_thread()

thread.info()

Message

Now we can create messages in the thread.

thread.create_message("tell me a joke")

thread.list_messages()

Run

after we added some messages we can create a run.

thread.create_run(assistant.id)

thread.list_runs()

thread.list_messages()

thread.list_messages()[0].info()

As you can see the run has generated a response to our message.

Roadmap

there are a lot of things that need to be done. a roadmap will be added soon.

Contact

Stefan Siegler: [email protected]

Project Link: https://github.com/XO30/gtp-assistants

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages