-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(openai-official): add OpenAI Responses API module #3078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,14 @@ private ModelContextWindows() {} | |
| Map.entry("o3-mini", 200_000), | ||
| Map.entry("o3", 200_000), | ||
| Map.entry("o1-mini", 128_000), | ||
| Map.entry("o1", 200_000)); | ||
| Map.entry("o1", 200_000), | ||
| Map.entry("gpt-5.4-mini", 400_000), | ||
|
jujn marked this conversation as resolved.
|
||
| Map.entry("gpt-5.4", 1_050_000), | ||
| Map.entry("gpt-5.5", 1_050_000), | ||
| Map.entry("gpt-5.6-luna", 1_050_000), | ||
| Map.entry("gpt-5.6-terra", 1_050_000), | ||
| Map.entry("gpt-5.6-sol", 1_050_000), | ||
| Map.entry("gpt-6-astra", 1_050_000)); | ||
|
|
||
| public static final Map<String, Integer> DEEPSEEK = | ||
| Map.ofEntries( | ||
|
|
@@ -77,6 +84,7 @@ private ModelContextWindows() {} | |
|
|
||
| public static final Map<String, Integer> GLM = | ||
| Map.ofEntries( | ||
| Map.entry("glm-5.3", 1_000_000), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Info]
jujn marked this conversation as resolved.
|
||
| Map.entry("glm-5.2", 1_000_000), | ||
| Map.entry("glm-5.1", 200_000), | ||
| Map.entry("glm-5-turbo", 200_000), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,12 +108,12 @@ | |
| <optional>true</optional> | ||
| </dependency> | ||
|
|
||
| <!-- <dependency>--> | ||
| <!-- <groupId>io.agentscope</groupId>--> | ||
| <!-- <artifactId>agentscope-extensions-model-openai-official</artifactId>--> | ||
| <!-- <scope>compile</scope>--> | ||
| <!-- <optional>true</optional>--> | ||
| <!-- </dependency>--> | ||
| <dependency> | ||
| <groupId>io.agentscope</groupId> | ||
| <artifactId>agentscope-extensions-model-openai-official</artifactId> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HIGH] Adding this module to |
||
| <scope>compile</scope> | ||
| <optional>true</optional> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.agentscope</groupId> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| /* | ||
| * Copyright 2024-2026 the original author or authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.agentscope.core.e2e.providers; | ||
|
|
||
| import io.agentscope.core.ReActAgent; | ||
| import io.agentscope.core.tool.Toolkit; | ||
| import io.agentscope.extensions.model.openaiofficial.OpenAIResponsesChatModel; | ||
| import io.agentscope.extensions.model.openaiofficial.ResponsesMultiAgentFormatter; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * Provider for OpenAI models via the official OpenAI Java SDK (Responses API). | ||
| */ | ||
| @ModelCapabilities({ModelCapability.BASIC, ModelCapability.TOOL_CALLING}) | ||
| public class OpenAIOfficialResponsesProvider extends BaseModelProvider { | ||
|
|
||
| private static final String API_KEY_ENV = "OPENAI_API_KEY"; | ||
| private static final String BASE_URL_ENV = "OPENAI_BASE_URL"; | ||
|
|
||
| public OpenAIOfficialResponsesProvider(String modelName, boolean multiAgentFormatter) { | ||
| super(API_KEY_ENV, modelName, multiAgentFormatter); | ||
| } | ||
|
|
||
| @Override | ||
| protected ReActAgent.Builder doCreateAgentBuilder(String name, Toolkit toolkit, String apiKey) { | ||
| String baseUrl = System.getenv(BASE_URL_ENV); | ||
|
jujn marked this conversation as resolved.
|
||
|
|
||
| OpenAIResponsesChatModel.Builder builder = | ||
| OpenAIResponsesChatModel.builder().apiKey(apiKey).modelName(getModelName()); | ||
|
|
||
| if (baseUrl != null && !baseUrl.isEmpty()) { | ||
| builder.baseUrl(baseUrl); | ||
| } | ||
|
|
||
| if (isMultiAgentFormatter()) { | ||
| builder.formatter(new ResponsesMultiAgentFormatter()); | ||
| } | ||
|
|
||
| return ReActAgent.builder().name(name).model(builder.build()).toolkit(toolkit); | ||
| } | ||
|
|
||
| @Override | ||
| public String getProviderName() { | ||
| return "OpenAI-Official"; | ||
|
jujn marked this conversation as resolved.
|
||
| } | ||
|
|
||
| @Override | ||
| public Set<ModelCapability> getCapabilities() { | ||
| Set<ModelCapability> caps = new HashSet<>(super.getCapabilities()); | ||
| if (isMultiAgentFormatter()) { | ||
| caps.add(ModelCapability.MULTI_AGENT_FORMATTER); | ||
| } | ||
| return caps; | ||
| } | ||
|
|
||
| // ========================================================================== | ||
| // Provider Instances | ||
| // ========================================================================== | ||
|
|
||
| /** GPT-5.4 via OpenAI Official SDK (Responses API). */ | ||
| @ModelCapabilities({ | ||
| ModelCapability.BASIC, | ||
| ModelCapability.TOOL_CALLING, | ||
| ModelCapability.THINKING | ||
| }) | ||
| public static class Gpt54 extends OpenAIOfficialResponsesProvider { | ||
| public Gpt54() { | ||
| super("gpt-5.4", false); | ||
| } | ||
|
|
||
| @Override | ||
| public String getProviderName() { | ||
| return "OpenAI-Official"; | ||
| } | ||
| } | ||
|
|
||
| /** GPT-5.4 with Multi-Agent Formatter. */ | ||
| @ModelCapabilities({ | ||
| ModelCapability.BASIC, | ||
| ModelCapability.TOOL_CALLING, | ||
| ModelCapability.THINKING, | ||
| ModelCapability.MULTI_AGENT_FORMATTER | ||
| }) | ||
| public static class Gpt54MultiAgent extends OpenAIOfficialResponsesProvider { | ||
| public Gpt54MultiAgent() { | ||
| super("gpt-5.4", true); | ||
| } | ||
|
|
||
| @Override | ||
| public String getProviderName() { | ||
| return "OpenAI-Official (Multi-Agent)"; | ||
|
jujn marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| ~ Copyright 2024-2026 the original author or authors. | ||
| ~ | ||
| ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
| ~ you may not use this file except in compliance with the License. | ||
| ~ You may obtain a copy of the License at | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, software | ||
| ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
| ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| ~ See the License for the specific language governing permissions and | ||
| ~ limitations under the License. | ||
| --> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>io.agentscope</groupId> | ||
| <artifactId>agentscope-extensions-model</artifactId> | ||
| <version>${revision}</version> | ||
| <relativePath>../pom.xml</relativePath> | ||
| </parent> | ||
|
|
||
| <artifactId>agentscope-extensions-model-openai-official</artifactId> | ||
| <name>AgentScope Java - Extensions - Model - OpenAI Official</name> | ||
| <description>OpenAI official SDK model provider extension for AgentScope Java</description> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>io.agentscope</groupId> | ||
| <artifactId>agentscope-core</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.openai</groupId> | ||
| <artifactId>openai-java</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.projectreactor</groupId> | ||
| <artifactId>reactor-core</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.agentscope</groupId> | ||
| <artifactId>agentscope-core</artifactId> | ||
| <version>${project.version}</version> | ||
| <type>test-jar</type> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.mockito</groupId> | ||
| <artifactId>mockito-core</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Warning] These context-window constants live in
agentscope-core, but they describe models served by the newagentscope-extensions-model-openai-officialmodule, and the existing entries in thisOPENAImap are consumed by the OpenAI chat-completions extension too. Per the repo guidance, changes to core cascade to harness, distribution and every extension, so a wrong number here silently mis-sizes compaction for anyone resolving by model name.Two asks:
gpt-5.4-miniat 400_000 againstgpt-5.4/5.5/5.6-*/6-astraat 1_050_000 is a wide spread, and a too-large value fails late (provider rejection) rather than early.