Skip to content

Commit 9d9cb7c

Browse files
authored
[Google] [PaLM] Support text prompt (#34)
2 parents 928b50e + dbca586 commit 9d9cb7c

28 files changed

Lines changed: 476 additions & 88 deletions

.java-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11.0

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<a href="https://claude.ai/" target="_blank">
3333
<img src="images/claude.png" alt="Claude" height="80" />
3434
</a>&nbsp;
35+
<a href="https://developers.generativeai.google/products/palm" target="_blank">
36+
<img src="images/google-palm.png" alt="Google PaLM" height="80" />
37+
</a>
3538
</div>
3639

3740
# How to use?

README.zh_CN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<a href="https://claude.ai/" target="_blank">
3333
<img src="images/claude.png" alt="Claude" height="80" />
3434
</a>&nbsp;
35+
<a href="https://developers.generativeai.google/products/palm" target="_blank">
36+
<img src="images/google-palm.png" alt="Google PaLM" height="80" />
37+
</a>
3538
</div>
3639

3740
# 如何使用?
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Completions
3+
---
4+
5+
!!! note
6+
7+
Support the google palm, product address: [https://developers.generativeai.google/products/palm](https://developers.generativeai.google/products/palm)
8+
9+
### Create completion
10+
11+
---
12+
13+
Creates a completion for the provided prompt and parameters.
14+
15+
```java
16+
// Automatic resource release
17+
try(OpenAiClient client=OpenAiClient.builder()
18+
.provider(ProviderModel.GOOGLE_PALM)
19+
.model(CompletionModel.TEXT_BISON_001)
20+
.apiKey(System.getProperty("google.token"))
21+
.build())
22+
{
23+
PromptEntity prompt = PromptEntity.builder()
24+
.text("How to create a completion")
25+
.build();
26+
CompletionEntity configure = CompletionEntity.builder()
27+
.prompt(prompt)
28+
.build();
29+
client.createPaLMCompletion(configure).getCandidates();
30+
}
31+
```
32+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Completions
3+
---
4+
5+
!!! note
6+
7+
支持 google palm,产品地址: [https://developers.generativeai.google/products/palm](https://developers.generativeai.google/products/palm)
8+
9+
### Create completion
10+
11+
---
12+
13+
为提供的提示和参数创建补全。
14+
15+
```java
16+
try(OpenAiClient client=OpenAiClient.builder()
17+
.provider(ProviderModel.GOOGLE_PALM)
18+
.model(CompletionModel.TEXT_BISON_001)
19+
.apiKey(System.getProperty("google.token"))
20+
.build())
21+
{
22+
PromptEntity prompt = PromptEntity.builder()
23+
.text("How to create a completion")
24+
.build();
25+
CompletionEntity configure = CompletionEntity.builder()
26+
.prompt(prompt)
27+
.build();
28+
client.createPaLMCompletion(configure).getCandidates();
29+
}
30+
```

docs/mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,7 @@ nav:
9292
- reference/azure/completions_chat.md
9393
- Anthropic Claude:
9494
- reference/anthropic/completions.md
95+
- Google PaLM:
96+
- reference/google_palm/completions.md
9597
- released.md
9698
- powered_by.md

images/google-palm.png

173 KB
Loading

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
<groupId>org.devlive.sdk</groupId>
77
<artifactId>openai-java-sdk</artifactId>
8-
<version>1.8.0</version>
8+
<version>1.9.0-SNAPSHOT</version>
99

1010
<name>openai-java-sdk</name>
1111
<description>
12-
Provides Java developers with a convenient, easy-to-use SDK to interact with OpenAI's apis.
12+
Provides an easy-to-use SDK for Java developers to interact with the APIs of open AI models.
1313
</description>
1414
<url>https://openai-java-sdk.devlive.org</url>
1515

src/main/java/org/devlive/sdk/openai/DefaultApi.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public interface DefaultApi
5757
Single<CompleteResponse> fetchCompletions(@Url String url,
5858
@Body CompletionEntity configure);
5959

60+
@POST
61+
Single<CompleteResponse> fetchPaLMCompletions(@Url String url,
62+
@Body org.devlive.sdk.openai.entity.google.CompletionEntity configure);
63+
6064
/**
6165
* Creates a model response for the given chat conversation.
6266
*/

src/main/java/org/devlive/sdk/openai/DefaultClient.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ public CompleteResponse createCompletion(CompletionEntity configure)
7373
}
7474
}
7575

76+
public CompleteResponse createPaLMCompletion(org.devlive.sdk.openai.entity.google.CompletionEntity configure)
77+
{
78+
return this.api.fetchPaLMCompletions(ProviderUtils.getUrl(provider, UrlModel.FETCH_COMPLETIONS), configure)
79+
.blockingGet();
80+
}
81+
7682
public ChatResponse createChatCompletion(ChatEntity configure)
7783
{
7884
String url = ProviderUtils.getUrl(provider, UrlModel.FETCH_CHAT_COMPLETIONS);

0 commit comments

Comments
 (0)