Expected Behavior

The feature should enable Spring AI to manage interactions with OpenAI's Assistant :

  • Managing Assistants: Provide API endpoints for creating, configuring, and managing instances of Assistants, allowing developers to tailor the behavior of these Assistants for specific tasks or user groups.

  • Threads Handling: Introduce functionality to manage conversation threads, enabling the application to handle ongoing dialogs, track conversation history, and maintain context across multiple interactions.

  • Messages Management: Offer methods to send and receive messages within a thread, including support for various message types such as text, images, and potentially complex interactive elements.

  • Files Processing: Enable the Assistant to process files submitted by users, such as documents for content extraction or images for analysis, and respond appropriately based on the content of these files.

  • Tools Integration:

  • Code Interpreter
  • Information Retrieval
  • Function Calling

Current Behavior

Currently, there's no built-in support within Spring AI for Assistant open AI API. Developers are required to build custom solutions for handling threads, managing messages, and processing files, which increases complexity and development time

Context

The need for such features arises from the growing demand for sophisticated AI-powered interactions within applications. By providing developers with the tools to manage Assistants, threads, messages, files, and integrating advanced functionalities directly, Spring AI can significantly reduce the development complexity and enable more powerful and interactive applications.

Comment From: cikichen

+1, urgent and necessary.

Comment From: jochenchrist

Also applies to Azure OpenAI

Comment From: bharatproductexpert

+1, urgent and necessary.

Comment From: meletis

+1

Comment From: andresssantos

+1, urgent and necessary.

Comment From: Ashakibp

+1 urgent

Comment From: evelzi

+1, urgent and necessary.

Comment From: Mr-LiuDC

+1, urgent and necessary.

Comment From: markpollack

Thanks for the votes. Will prioritize

Comment From: Alio-Kh

+1, urgent and necessary.

Comment From: mettbest

very urgent, is there any ETA for final release of 1.0.0-RC1 ?

Comment From: ThomasVitale

For people interested in this feature, I would recommend adding a "thumb up" to the issue description instead of commenting with "+1", reserving comments to discuss the feature implementation ideas and details. Thanks!

Comment From: hedaoming

Currently, there is no access method for Assistant API provided in spring ai. So how do you implement multi-round dialogue? I plan to use ChatMemory to achieve

Comment From: olixva

+1 urgent, any news?

Comment From: donnior

+1, urgent and necessary.

Comment From: cblume

+1, urgent and necessary

Comment From: humanry

+1

Comment From: hb12devtn

+1

Comment From: humanry

please consiser doing it for Azure Open AI as that is more focused on enterprise use cases

Comment From: fedecompa

Very urgent and necessary.

Comment From: apappascs

Hi @markpollack,

I’d like to take on this ticket and have already started integrating the OpenAI Assistant API.

To align with Spring's principles of modularity and extensibility, I'm proposing to create a new assistant package under models/spring-ai-openai/src/main/java/org/springframework/ai/openai and spring-ai-core/src/main/java/org/springframework/ai. This focused implementation will allow us to establish clean, provider-agnostic abstractions that can support multiple AI assistant providers over time.

Code Sketch

The implementation will include the following abstractions for managing assistants, threads, and messages, based on OpenAI’s endpoints:

AssistantManager Handles operations related to assistant lifecycle management.

public interface AssistantManager {
    Assistant createAssistant(AssistantCreationOptions options);
    List<Assistant> listAssistants();
    Assistant getAssistant(String assistantId);
    Assistant modifyAssistant(String assistantId, AssistantModificationOptions options);
    void deleteAssistant(String assistantId);
}

ThreadManager Manages conversation threads and their lifecycle.

public interface ThreadManager {
    Thread createThread(String assistantId, ThreadCreationOptions options);
    Thread getThread(String threadId);
    Thread modifyThread(String threadId, ThreadModificationOptions options);
    void deleteThread(String threadId);
}

MessageManager Facilitates sending, receiving, and managing messages within a thread.

public interface MessageManager {
    Message createMessage(String threadId, MessageCreationOptions options);
    List<Message> listMessages(String threadId);
    Message getMessage(String messageId);
    Message modifyMessage(String messageId, MessageModificationOptions options);
    void deleteMessage(String messageId);
}

OpenAI Implementation

public class OpenAiAssistantManager implements AssistantManager {
    private final OpenAiAssistantApi client;

    @Override
    public Assistant createAssistant(AssistantCreationOptions options) {
        // Call OpenAI API for creating an assistant
    }

    @Override
    public List<Assistant> listAssistants() {
        // Call OpenAI API for listing assistants
    }

    @Override
    public Assistant getAssistant(String assistantId) {
        // Call OpenAI API for retrieving an assistant
    }

    @Override
    public Assistant modifyAssistant(String assistantId, AssistantModificationOptions options) {
        // Call OpenAI API for modifying an assistant
    }

    @Override
    public void deleteAssistant(String assistantId) {
        // Call OpenAI API for deleting an assistant
    }
}

This design aims to provide a generic framework for assistant management, with OpenAI as the initial implementation. Over time, it could evolve into a spring-ai-assistant module, supporting multiple providers and further extending the Spring AI ecosystem.

Please let me know if you have any suggestions or if there's anything I should adjust to better fit the project's direction.