https://github.com/raheesahmed/openai-assistant-sdk
This package provides an easy-to-use interface for interacting with OpenAI's API to manage assistants, threads, messages, and runs.
https://github.com/raheesahmed/openai-assistant-sdk
assistant-api openai openai-assistants openai-assistants-api
Last synced: about 4 hours ago
JSON representation
This package provides an easy-to-use interface for interacting with OpenAI's API to manage assistants, threads, messages, and runs.
- Host: GitHub
- URL: https://github.com/raheesahmed/openai-assistant-sdk
- Owner: RaheesAhmed
- License: mit
- Created: 2024-08-18T01:33:45.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-08-18T01:49:45.000Z (9 months ago)
- Last Synced: 2024-12-25T13:41:11.165Z (5 months ago)
- Topics: assistant-api, openai, openai-assistants, openai-assistants-api
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.MD
- License: LICENSE.md
Awesome Lists containing this project
README
# OpenAI Assistant SDK
**⚠️ UNDER DEVELOPMENT: This package is currently in active development and not ready for production use.**
This package provides an easy-to-use interface for interacting with OpenAI's API to manage assistants, threads, messages, and runs.
## Features
- Create, retrieve, update, and delete Assistants.
- Manage threads to handle conversations.
- Send and manage messages within threads.
- Initiate and control runs for processing interactions.## Installation
You can add this package to your project by including it in your JavaScript environment. Ensure you have `axios` installed:
```bash
npm install axios
```## Usage
Here is a basic example of how to use the `OpenAIAssistant` class to interact with OpenAI's API.```javascript
import OpenAIAssistant from './OpenAIAssistant.js';const apiKey = 'your-openai-api-key';
const assistant = new OpenAIAssistant(apiKey);async function createAndManageAssistant() {
const assistantData = {
model: 'gpt-4o',
instructions: 'You are a helpful assistant.',
name: 'My Assistant'
};// Create a new assistant
const newAssistant = await assistant.createAssistant(assistantData);
console.log('Assistant Created:', newAssistant);// Retrieve an assistant
const fetchedAssistant = await assistant.retrieveAssistant(newAssistant.id);
console.log('Assistant Details:', fetchedAssistant);
}createAndManageAssistant();
```## Methods
The SDK includes several methods for interacting with the OpenAI API:
- `createAssistant(data)`
- `listAssistants()`
- `retrieveAssistant(assistantId)`
- `updateAssistant(assistantId, data)`
- `deleteAssistant(assistantId)`
- `createThread(data)`
- `retrieveThread(threadId)`
- `updateThread(threadId, data)`
- `deleteThread(threadId)`
- `createMessage(threadId, data)`
- `retrieveMessage(threadId, messageId)`
- `listMessages(threadId)`
- `updateMessage(threadId, messageId, data)`
- `deleteMessage(threadId, messageId)`
- `createRun(threadId, data)`
- `retrieveRun(threadId, runId)`
- `listRuns(threadId)`
- `cancelRun(threadId, runId)`## Configuration
Ensure your API key is securely stored and not hardcoded in your production applications.For detailed API documentation and more examples, visit [OpenAI API Documentation](https://openai.com/docs/).
## License
This project is licensed under the MIT License - See the [LICENSE.md](LICENSE.md) file for details..