Add role "documents" to support Granite RAG

Open
#2,204 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
java, spring
Domain
api, backend

Research direction

Start by inspecting org.springframework.ai.chat.messages.AbstractMessage#messageType and org.springframework.ai.ollama.api.OllamaApi.Message#role, which the issue identifies as enum-based entry points. Check how these roles are serialized for Ollama, then define completion as allowing the documents role to be sent through ChatModel or OllamaApi for Granite RAG use cases.

Written by the indexing model from the issue text.

Description

status: waiting-for-triage

Granite 3.1 introduced the role documents to support RAG use cases (https://www.ibm.com/granite/docs/models/granite/#retrieval-augmented-generation-(rag))
We did some explanatory testing with Ollama and the results are very promising.

Currently org.springframework.ai.chat.messages.AbstractMessage#messageType and org.springframework.ai.ollama.api.OllamaApi.Message#role are enumerations, which makes it impossible to use ChatModel or OllamaApi to sent this type of message to the LLM.
The use of enumerations in the context of Ollama might be a bit restrictive (every open-source model could decide to use an currently unknown role).

For now, extending the enum would give us the opportunity to create a custom advisor to use the new RAG approach from Granite.
For the long term, I feel OllamaChatModel and OllamaApi should not be restricted by enumerations.

Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 10h
Merged PRs (30d)
5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from spring-projects/spring-ai

All issues in spring-projects/spring-ai

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.