OPENAI-CONNECTOR

Empowering Conversations: OpenAI-Connector Unlocks AI Brilliance

license last-commit repo-top-language repo-language-count

Developed with the software and tools below.

JavaScript OpenAI Express JSON


Quick Links


Overview

The OpenAI-Connector project energizes messaging features by seamlessly interacting with OpenAI's AI assistants. It streamlines the organization of message threads, assists in listing and managing AI assistants efficiently, and facilitates smooth user interactions through APIs for sending and retrieving messages. This system empowers developers to create and manage conversational AI experiences, enhancing user engagement and conversation management within applications.


Features

Feature Description
โš™๏ธ Architecture Built on Express.js, the project's architecture is structured with controllers and services for handling API requests efficiently. It leverages OpenAI integration for conversational AI capabilities, enhancing messaging features.
๐Ÿ”ฉ Code Quality The codebase maintains a clean structure with modular components, following JavaScript best practices. Proper error handling and consistent coding style ensure readability and maintainability.
๐Ÿ“„ Documentation The project includes detailed API documentation using Swagger, enhancing developer understanding and facilitating integration. Code comments and clear function descriptions further aid in comprehending the codebase.
๐Ÿ”Œ Integrations Key integrations include Express for web framework, Swagger for API documentation, and OpenAI for conversational AI features. External dependencies such as swagger-ui-express are utilized for enhancing functionality.
๐Ÿงฉ Modularity The codebase exhibits high modularity with separate controllers, services, and utility functions for distinct functionalities. This design promotes reusability and maintainability across different parts of the project.
๐Ÿงช Testing The project utilizes testing frameworks for ensuring code correctness and reliability. Unit tests and integration tests are likely employed to validate the functionality of various components.
โšก๏ธ Performance Efficiency is maintained through streamlined API routes and optimized processing of AI assistant interactions. Proper resource management and caching mechanisms may contribute to speedy responses.
๐Ÿ›ก๏ธ Security Measures like API key configuration in the OpenAI file ensure secure access to external services. Provisions for data encryption and access control mechanisms may be implemented to safeguard sensitive information.
๐Ÿ“ฆ Dependencies Project dependencies include Express, Swagger, and OpenAI libraries for core functionalities. Additional libraries like swagger-jsdoc are used for enhancing API documentation capabilities.

Repository Structure

โ””โ”€โ”€ OpenAI-Connector/
    โ”œโ”€โ”€ config.env
    โ”œโ”€โ”€ package-lock.json
    โ”œโ”€โ”€ package.json
    โ””โ”€โ”€ src
        โ”œโ”€โ”€ app.js
        โ”œโ”€โ”€ config
        โ”‚   โ””โ”€โ”€ openAI.js
        โ”œโ”€โ”€ controller
        โ”‚   โ””โ”€โ”€ assistant
        โ”‚       โ”œโ”€โ”€ listAssistants.controller.js
        โ”‚       โ”œโ”€โ”€ message
        โ”‚       โ”‚   โ”œโ”€โ”€ listMessages.controller.js
        โ”‚       โ”‚   โ””โ”€โ”€ sendMessage.controller.js
        โ”‚       โ””โ”€โ”€ thread
        โ”‚           โ”œโ”€โ”€ createThread.controller.js
        โ”‚           โ””โ”€โ”€ deleteThread.controller.js
        โ”œโ”€โ”€ routes
        โ”‚   โ”œโ”€โ”€ assistant.routes.js
        โ”‚   โ””โ”€โ”€ index.routes.js
        โ”œโ”€โ”€ service
        โ”‚   โ””โ”€โ”€ assistant
        โ”‚       โ””โ”€โ”€ message
        โ”‚           โ””โ”€โ”€ sendMessage.service.js
        โ””โ”€โ”€ util
            โ”œโ”€โ”€ createMessage.js
            โ”œโ”€โ”€ createNewThread.js
            โ”œโ”€โ”€ deleteThread.js
            โ”œโ”€โ”€ listAssistants.js
            โ”œโ”€โ”€ listMessages.js
            โ”œโ”€โ”€ retrieveAssistant.js
            โ””โ”€โ”€ retrieveMessage.js

Modules

.
File Summary
package.json Code snippet in sendMessage.controller.js lists messages in a thread. Enhances OpenAI-Connector's API by organizing thread messages efficiently. Energizes messaging features for smooth user interactions.
package-lock.json Code snippet defines OpenAI API configurations, enhancing assistant listing in the app. Supports easier integration and management. Situated in config/openAI.js.
src
File Summary
app.js Code snippet in src/app.js initializes an Express app, sets up OpenAPI documentation using swagger-jsdoc, and defines API routes for interacting with OpenAI Assistant. It also listens on a specified port.
src.controller.assistant
File Summary
listAssistants.controller.js Code snippet in listAssistants.controller.js handles GET request to list assistants. It fetches and returns assistant data, ensuring error handling.
src.controller.assistant.message
File Summary
listMessages.controller.js Code Summary:**This code snippet in listMessages.controller.js retrieves all messages for a given thread ID. Key features include fetching messages and handling error responses in the OpenAI-Connector project's message listing functionality.
sendMessage.controller.js Code Summary:** Send message to assistant. Handles POST request, sends message with thread ID, context, and assistant ID. Returns message response or internal server error.
src.controller.assistant.thread
File Summary
deleteThread.controller.js Code Summary:**deleteThread.controller.js manages deleting threads from the OpenAI Connector system. It responds with successful deletion or error messages, supporting the architecture's thread-related functionalities.
createThread.controller.js Code snippet: createThread.controller.jsSummary: Manages creating new threads in the OpenAI-Connector repository. Provides endpoint for creating threads with response handling.
src.util
File Summary
listAssistants.js Role:** listAssistants.js fetches a list of assistants from OpenAI, integrated via openAI.js. It aids in managing AI assistant entities within the system's architecture.
createNewThread.js Role: createNewThread.js** Creates a new thread using OpenAI, returning the thread ID. Key part of OpenAI-Connector's architecture for managing conversations efficiently.
deleteThread.js Code Summary:** deleteThread.js facilitates deleting a thread through the OpenAI-Connector by leveraging the openAIConnector config, enhancing thread management efficiency in the repository's architecture.
createMessage.js Code Summary:**createMessage.js in OpenAI-Connector initializes a user message in a thread, triggers an assistant run, and retrieves the response for further interactions in the conversational AI system.
retrieveMessage.js Code Summary:**retrieveMessage.js fetches message data from OpenAI's API using provided threadId and runId. Key role: retrieve message details asynchronously. Contributing to AI-driven chatbot functionality in OpenAI-Connector.
retrieveAssistant.js Summary:** Retrieves assistant information using OpenAI API. Integrates with parent repository's architecture via config. Simplifies access to assistant data.
listMessages.js Role**: listMessages.js lists messages for a given thread using OpenAI Connector.Features: Fetches messages from OpenAI and returns them for display.
src.config
File Summary
openAI.js Role:** Configuring OpenAI API key for OpenAI-Connector.Features: Sets up OpenAI client with API key from config, logging configured status.References src/config/openAI.js in the OpenAI-Connector repo.
src.routes
File Summary
assistant.routes.js Code Summary:****assistant.routes.js** organizes assistant-related API routes using Express Router, invoking controllers for listing assistants, sending messages, managing threads. Facilitates structured interaction within OpenAI-Connector.
index.routes.js Summary:**index.routes.js in OpenAI-Connector repo routes requests to assistant functionalities. Facilitates modularization and scalability in the repository's architecture.
src.service.assistant.message
File Summary
sendMessage.service.js Role:** sendMessageService function in assistant/message sub-module.Features: Handles sending messages to a thread in OpenAI-Connector app through createMessage util with error handling.

Getting Started

Requirements

Ensure you have the following dependencies installed on your system:

  • JavaScript: version x.y.z

Installation

  1. Clone the OpenAI-Connector repository:
git clone https://github.com/thadeucbr/OpenAI-Connector
  1. Change to the project directory:
cd OpenAI-Connector
  1. Install the dependencies:
npm install

Running OpenAI-Connector

Use the following command to run OpenAI-Connector:

node app.js

Tests

Use the following command to run tests:

npm test

Project Roadmap

  • โ–บ INSERT-TASK-1
  • โ–บ INSERT-TASK-2
  • โ–บ ...

Contributing

Contributions are welcome! Here are several ways you can contribute:

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/thadeucbr/OpenAI-Connector
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to GitHub: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.

Once your PR is reviewed and approved, it will be merged into the main branch.


License

This project is protected under the SELECT-A-LICENSE License. For more details, refer to the LICENSE file.


Acknowledgments

  • List any resources, contributors, inspiration, etc. here.

Return