Skip to content

Commit 21d7cdd

Browse files
committed
Add VertexAi Embeddings Docs + clear READMEs
1 parent 7ea867d commit 21d7cdd

File tree

21 files changed

+226
-62
lines changed

21 files changed

+226
-62
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Azure OpenAI
22

3-
Visit the Spring AI [Azure OpenAI Chat Documentation](https://docs.spring.io/spring-ai/reference/api/clients/azure-openai-chat.html).
3+
Visit the Spring AI
4+
- [Azure OpenAI Chat Documentation](https://docs.spring.io/spring-ai/reference/api/clients/azure-openai-chat.html).
5+
- [Azure OpenAI Embedding Documentation](https://docs.spring.io/spring-ai/reference/api/embeddings/azure-openai-embeddigs.html).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Huggingface Chat
2+
3+
Visit the Spring AI
4+
- [Huggingface Chat Documentation](https://docs.spring.io/spring-ai/reference/api/clients/huggingface.html).
5+

models/spring-ai-ollama/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Ollama Chat
22

3-
Visit the Spring AI [Ollama Chat Documentation](https://docs.spring.io/spring-ai/reference/api/clients/ollama-chat.html).
3+
Visit the Spring AI
4+
- [Ollama Chat Documentation](https://docs.spring.io/spring-ai/reference/api/clients/ollama-chat.html).
5+
- [Ollama Embedding Documentation](https://docs.spring.io/spring-ai/reference/api/embeddings/ollama-embeddings.html).

models/spring-ai-openai/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# OpenAI Chat
22

3-
Visit the Spring AI [OpenAI Chat Documentation](https://docs.spring.io/spring-ai/reference/api/clients/openai-chat.html).
3+
Visit the Spring AI
4+
- [OpenAI Chat Documentation](https://docs.spring.io/spring-ai/reference/api/clients/openai-chat.html).
5+
- [OpenAI Embedding Documentation](https://docs.spring.io/spring-ai/reference/api/embeddings/openai-embeddings.html).
6+

models/spring-ai-postgresml/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# PostgresML Embeddings
2+
3+
Visit the Spring AI
4+
- [PostgresML Embedding Documentation](https://docs.spring.io/spring-ai/reference/api/embeddings/postgresml-embeddings.html).
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Transformers (ONNX) Embeddings
2+
3+
Visit the Spring AI:
4+
- [Transformers Embedding Documentation](https://docs.spring.io/spring-ai/reference/api/embeddings/onnx.html).
5+
6+

models/spring-ai-vertex-ai/README.md

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,6 @@
1+
# Vertex AI
12

2-
# Vertex AI API client for the Generative Language model
3+
Visit the Spring AI:
4+
- [VertexAI Chat Documentation](https://docs.spring.io/spring-ai/reference/api/clients/vertexai-chat.html).
5+
- [VertexAI Embedding Documentation](https://docs.spring.io/spring-ai/reference/api/embeddings/vertexai-embeddings.html).
36

4-
The [Generative Language](https://developers.generativeai.google/api/rest/generativelanguage) PaLM API allows developers to build generative AI applications using the PaLM model. Large Language Models (LLMs) are a powerful, versatile type of machine learning model that enables computers to comprehend and generate natural language through a series of prompts. The PaLM API is based on Google's next generation LLM, PaLM. It excels at a variety of different tasks like code generation, reasoning, and writing. You can use the PaLM API to build generative AI applications for use cases like content generation, dialogue agents, summarization and classification systems, and more.
5-
6-
Based on the [Models REST API](https://developers.generativeai.google/api/rest/generativelanguage/models).
7-
8-
## Prerequisite
9-
10-
To access the PaLM2 REST API you need to obtain an access API KEY form [makersuite](https://makersuite.google.com/app/apikey).
11-
Note: Currently it is not available outside US, but you can use VPN for testing.
12-
13-
## PaLM API
14-
15-
The VertexAI, ChatClient and EmbeddingClient are built on top the [VertexAiApi.java](./src/main/java/org/springframework/ai/vertex/api/VertexAiApi.java) client library:
16-
17-
![PaLM API](./src/test/resources/Google%20Generative%20AI%20-%20PaLM2%20REST%20API.jpg)
18-
19-
Following snippets show how to use the `VertexAiApi` client directly:
20-
21-
```java
22-
23-
VertexAiApi vertexAiApi = new VertexAiApi(< YOUR PALM_API_KEY>);
24-
25-
// Generate
26-
var prompt = new MessagePrompt(List.of(new Message("0", "Hello, how are you?")));
27-
28-
GenerateMessageRequest request = new GenerateMessageRequest(prompt);
29-
30-
GenerateMessageResponse response = vertexAiApi.generateMessage(request);
31-
32-
// Embed text
33-
Embedding embedding = vertexAiApi.embedText("Hello, how are you?");
34-
35-
// Batch embedding
36-
List<Embedding> embeddings = vertexAiApi.batchEmbedText(List.of("Hello, how are you?", "I am fine, thank you!"));
37-
```

models/spring-ai-vertex-ai/src/test/java/org/springframework/ai/vertex/VertexAiEmbeddingClientIT.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
package org.springframework.ai.vertex;
22

3+
import java.util.List;
4+
35
import org.junit.jupiter.api.Test;
46
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
57

68
import org.springframework.ai.embedding.EmbeddingResponse;
7-
import org.springframework.ai.vertex.VertexAiEmbeddingClient;
89
import org.springframework.ai.vertex.api.VertexAiApi;
910
import org.springframework.beans.factory.annotation.Autowired;
1011
import org.springframework.boot.SpringBootConfiguration;
1112
import org.springframework.boot.test.context.SpringBootTest;
1213
import org.springframework.context.annotation.Bean;
1314

14-
import java.util.List;
15-
1615
import static org.assertj.core.api.Assertions.assertThat;
1716

1817
@SpringBootTest

spring-ai-docs/src/main/antora/modules/ROOT/nav.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
* xref:getting-started.adoc[Getting Started]
44
* xref:api/index.adoc[]
55
** xref:api/embeddings.adoc[]
6-
*** xref:api/embeddings/onnx.adoc[]
76
*** xref:api/embeddings/openai-embeddings.adoc[]
87
*** xref:api/embeddings/ollama-embeddings.adoc[]
98
*** xref:api/embeddings/azure-openai-embeddings.adoc[]
109
*** xref:api/embeddings/postgresml-embeddings.adoc[]
11-
*** xref:api/bedrock.adoc[Amazon Bedrock Embedding]
10+
*** xref:api/embeddings/vertexai-embeddings.adoc[]
11+
*** xref:api/bedrock.adoc[Amazon Bedrock Embeddings]
1212
**** xref:api/embeddings/bedrock-cohere-embedding.adoc[]
1313
**** xref:api/embeddings/bedrock-titan-embedding.adoc[]
14+
*** xref:api/embeddings/onnx.adoc[]
1415
** xref:api/chatclient.adoc[]
1516
*** xref:api/clients/openai-chat.adoc[]
1617
*** xref:api/clients/azure-openai-chat.adoc[]

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/clients/azure-openai-chat.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public class ChatController {
135135
return Map.of("generation", chatClient.generate(message));
136136
}
137137
138-
@GetMapping("/open-ai/generateStream")
138+
@GetMapping("/ai/generateStream")
139139
public Flux<ChatResponse> generateStream(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
140140
Prompt prompt = new Prompt(new UserMessage(message));
141141
return chatClient.stream(prompt);

0 commit comments

Comments
 (0)