supershaneski / openai-assistants-api-streaming

A sample application to demonstrate OpenAI Assistants API streaming, built using Next.js.
MIT License
17 stars 3 forks source link

Support for Retrieval and CodeInterpreter Tools with Generic Interface for Extensibility #1

Open eqbal opened 4 months ago

eqbal commented 4 months ago

First off, amazing work on the openai-assistants-api-streaming project! It’s incredibly useful and well-documented, and I appreciate the effort to make the streaming capabilities more accessible.

I've been exploring your project and noticed it currently does not handle Retrieval or CodeInterpreter tools, which are pivotal for a range of applications using the OpenAI API. Integrating these tools could greatly enhance the project's capabilities, enabling users to implement more complex functionalities.

Do you think we can Enhance the thread.runs.create method to include a tools parameter that specifies which tools (e.g., retrieval, code_interpreter) the assistant can use. This would allow the assistant to leverage these tools dynamically based on user needs.

while(!is_completed) {
    let stream = tool_outputs.length === 0 ? await openai.beta.threads.runs.create(
        thread_id, {
            assistant_id: process.env.OPENAI_ASSISTANT_ID,
            stream: true,
            tools: ["code_interpreter", "retrieval"] // Enabling tools
        }
    ) : openai.beta.threads.runs.submitToolOutputsStream(
        thread_id,
        run_id,
        { tool_outputs }
    );

}

Additionally, I found the use of mockAPI in the codebase a bit confusing. Could you clarify its purpose? Perhaps consider enhancing the documentation or examples around this to better illustrate its usage and integration.

By making the project's architecture more generic and flexible, it could serve as a robust template for any OpenAI Assistant API project, allowing users to easily plug in different functionalities while maintaining full control over the tools and API interactions.

adriaanrijkens commented 4 months ago

Cool idea. Indeed it would be great if this project can server as a general template for OpenAI and maybe even in the future other AI APIs!

bayrami1 commented 4 months ago

The mockAPI is used in the demo for the readme