Skip to content

Commit 93781d9

Browse files
committed
[Google] [Gemini] 修改流式输出调用 API
1 parent cacdc42 commit 93781d9

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/main/java/org/devlive/sdk/openai/model/CompletionModel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public enum CompletionModel
6464
"Most capable model in the GPT-3 series. Can perform any task the other GPT-3 models can, often with higher quality, longer output and better instruction-following. It can process up to 4,000 tokens per request.",
6565
"Complex intent, cause and effect, creative generation, search, summarization for audience",
6666
4097),
67+
@Deprecated
6768
TEXT_DAVINCI_003("text-davinci-003",
6869
"Most capable model in the GPT-3 series. Can perform any task the other GPT-3 models can, often with higher quality, longer output and better instruction-following. It can process up to 4,000 tokens per request.",
6970
"Complex intent, cause and effect, creative generation, search, summarization for audience",
@@ -134,7 +135,7 @@ public enum CompletionModel
134135
null,
135136
32768),
136137

137-
GPT_4O("gpt-4o",
138+
GPT_4O("gpt-4o",
138139
"most advanced, multimodal flagship model that’s cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13",
139140
null,
140141
128000),

src/main/java/org/devlive/sdk/platform/google/interceptor/GoogleInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected Request prepared(Request original)
3939
List<String> pathSegments = Lists.newArrayList();
4040
httpUrl = HttpUrlUtils.removePathSegment(httpUrl);
4141
// https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=YOUR_API_KEY
42-
pathSegments.add(0, String.join(":", getModel(), "generateContent"));
42+
pathSegments.add(0, String.join(":", getModel(), stream ? "streamGenerateContent" : "generateContent"));
4343
pathSegments.add(0, "models");
4444
pathSegments.add(0, version.getVersion());
4545
httpUrl = httpUrl.newBuilder()

src/test/java/org/devlive/sdk/openai/StreamClientTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.google.common.collect.Lists;
44
import lombok.extern.slf4j.Slf4j;
5+
import org.devlive.sdk.ResourceUtils;
56
import org.devlive.sdk.common.listener.ConsoleEventSourceListener;
67
import org.devlive.sdk.openai.entity.ChatEntity;
78
import org.devlive.sdk.openai.entity.CompletionEntity;
@@ -26,7 +27,7 @@ public void before()
2627
.countDownLatch(countDownLatch)
2728
.build();
2829
client = OpenAiClient.builder()
29-
.apiKey(System.getProperty("openai.token"))
30+
.apiKey(ResourceUtils.getValue("openai.token"))
3031
.listener(listener)
3132
.build();
3233
}

0 commit comments

Comments
 (0)