spring-projects / spring-projects/spring-ai
Vertex RAG Corpus can be with RagResource in VertexAiGeminiChatModel
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Please do a quick search on GitHub issues first, the feature you are about to request might have already been requested.
Expected Behavior
VertexAiGeminiChatModel passes RagCorpus as Retrieval.
Current Behavior
Now, VertexAiGeminiChatModel.createGeminiRequest() supports functions definitions, and GoogleSearch only.
Context
How has this issue affected you?
There seems to be no way to use Rag Corpus in GCP
What are you trying to accomplish?
I am trying to make the call with
"retrieval": {
"vertexRagStore": {
"ragResources": [
{
"ragCorpus": "projects/{project_id}/locations/{localtion}/ragCorpora/{rag_corpus_id}"
}
],
"ragRetrievalConfig": {
"filter": {
"vectorSimilarityThreshold": 0.5
},
"topK": 3
}
}
}
What other alternatives have you considered?
I have considered using native google genai SDK
Are you aware of any workarounds?
Adding the following lines will make it work.
line 714- in VertexAiGeminiChatModel.java
if (prompt.getOptions() instanceof VertexAiGeminiChatOptions options && !StringUtil.isNullOrEmpty(options.getRagCorpus())) {
final Tool ragCorpusTool = Tool.newBuilder()
.setRetrieval(
Retrieval.newBuilder().setVertexRagStore(VertexRagStore.newBuilder()
.addRagResources(
0,
VertexRagStore.RagResource.newBuilder()
.setRagCorpus(options.getRagCorpus())
.build()
).build()
).build()
).build();
tools.add(ragCorpusTool);
}
line 152- in VertexAiGeminiChatOptions.java
/**
* Use Google RAG Corpus feature
*/
@JsonIgnore
private String ragCorpus;
...
// add Getter and Setter
...
This works with other tools correctly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by searching existing GitHub issues, then inspect VertexAiGeminiChatModel.java around line 714 and VertexAiGeminiChatOptions.java around line 152. Trace how existing function definitions and GoogleSearch tools are added, and use the provided RagResource example as the expected behavior. Done means VertexAiGeminiChatModel can send a Vertex RAG Corpus while preserving other tools.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- google-cloud, java
- Domain
- ai, cloud
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100