Skip to content

thalesfsp/openai-assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenAI Assistant Integration

This project demonstrates the integration of the OpenAI Assistant feature and API in both Golang (CLI) and Python (API).

Installation

Clone the repository and navigate to the project directory:

git clone <repository-url>
cd <project-directory>

Install the Go dependencies:

go mod download

Set up the Python environment:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Usage

Golang CLI

You can run the Golang CLI project with the following commands:

go run main.go "Some question"
go run main.go "Some question" "thread_123"
go run main.go "Some question" "thread_123" "msg_AZS"

Python API

To run the Python API project:

python3 main.py

In another terminal, you can send requests to the API:

QUESTION="Some question" curl --location 'http://localhost:38234/api/v1/message' \
    --header 'Content-Type: application/json' \
    --data '{
    "question": "$QUESTION",
}'

QUESTION="Some question" curl --location 'http://localhost:38234/api/v1/message' \
    --header 'Content-Type: application/json' \
    --data '{
    "question": "$QUESTION",
    "thread_id": "thread_123",
}'

QUESTION="Some question" curl --location 'http://localhost:38234/api/v1/message' \
    --header 'Content-Type: application/json' \
    --data '{
    "question": "$QUESTION",
    "thread_id": "thread_123",
    "after_message_id": "msg_AZS"
}'

Contributing

Contributions are welcome. Please make sure to update tests as appropriate.

License

MIT