Skip to content

Commit 88eb0f5

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: Add ChatCompletionsRequest object
This is part of a larger chain of commits for adding chat completion API support to the Apigee model. PiperOrigin-RevId: 894295669
1 parent 7407e37 commit 88eb0f5

6 files changed

Lines changed: 1369 additions & 229 deletions

File tree

core/src/main/java/com/google/adk/models/ChatCompletionsResponse.java

Lines changed: 0 additions & 224 deletions
This file was deleted.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright 2026 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.adk.models.chat;
18+
19+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
20+
import com.fasterxml.jackson.annotation.JsonInclude;
21+
import com.fasterxml.jackson.annotation.JsonProperty;
22+
import java.util.Map;
23+
24+
/** Shared models for Chat Completions Request and Response. */
25+
@JsonIgnoreProperties(ignoreUnknown = true)
26+
@JsonInclude(JsonInclude.Include.NON_NULL)
27+
final class ChatCompletionsCommon {
28+
29+
private ChatCompletionsCommon() {}
30+
31+
/**
32+
* See
33+
* https://developers.openai.com/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_message_tool_call%20%3E%20(schema)
34+
*/
35+
@JsonIgnoreProperties(ignoreUnknown = true)
36+
@JsonInclude(JsonInclude.Include.NON_NULL)
37+
static class ToolCall {
38+
/** See class definition for more details. */
39+
public Integer index;
40+
41+
/** See class definition for more details. */
42+
public String id;
43+
44+
/** See class definition for more details. */
45+
public String type;
46+
47+
/** See class definition for more details. */
48+
public Function function;
49+
50+
/** See class definition for more details. */
51+
public Custom custom;
52+
53+
/**
54+
* Used to supply additional parameters for specific models, for example:
55+
* https://ai.google.dev/gemini-api/docs/openai#thinking
56+
*/
57+
@JsonProperty("extra_content")
58+
public Map<String, Object> extraContent;
59+
}
60+
61+
/**
62+
* See
63+
* https://developers.openai.com/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_message_function_tool_call%20%3E%20(schema)
64+
*/
65+
@JsonIgnoreProperties(ignoreUnknown = true)
66+
@JsonInclude(JsonInclude.Include.NON_NULL)
67+
static class Function {
68+
/** See class definition for more details. */
69+
public String name;
70+
71+
/** See class definition for more details. */
72+
public String arguments; // JSON string
73+
}
74+
75+
/**
76+
* See
77+
* https://developers.openai.com/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_custom_tool%20%3E%20(schema)
78+
*/
79+
@JsonIgnoreProperties(ignoreUnknown = true)
80+
@JsonInclude(JsonInclude.Include.NON_NULL)
81+
static class Custom {
82+
/** See class definition for more details. */
83+
public String input;
84+
85+
/** See class definition for more details. */
86+
public String name;
87+
}
88+
}

0 commit comments

Comments
 (0)