Skip to content
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

chore: simplify examples involving lists #118

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,12 @@ import com.openai.models.ChatCompletionCreateParams;
import com.openai.models.ChatCompletionMessageParam;
import com.openai.models.ChatCompletionUserMessageParam;
import com.openai.models.ChatModel;
import java.util.List;

ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
.messages(List.of(ChatCompletionMessageParam.ofChatCompletionUserMessageParam(ChatCompletionUserMessageParam.builder()
.addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam(ChatCompletionUserMessageParam.builder()
.role(ChatCompletionUserMessageParam.Role.USER)
.content(ChatCompletionUserMessageParam.Content.ofTextContent("Say this is a test"))
.build())))
.build()))
.model(ChatModel.O1)
.build();
ChatCompletion chatCompletion = client.chat().completions().create(params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ class AssistantTest {
.model("model")
.name("name")
.object_(Assistant.Object.ASSISTANT)
.tools(
listOf(
AssistantTool.ofCodeInterpreterTool(
CodeInterpreterTool.builder()
.type(CodeInterpreterTool.Type.CODE_INTERPRETER)
.build()
)
.addTool(
AssistantTool.ofCodeInterpreterTool(
CodeInterpreterTool.builder()
.type(CodeInterpreterTool.Type.CODE_INTERPRETER)
.build()
)
)
.responseFormat(
Expand All @@ -39,12 +37,12 @@ class AssistantTest {
Assistant.ToolResources.builder()
.codeInterpreter(
Assistant.ToolResources.CodeInterpreter.builder()
.fileIds(listOf("string"))
.addFileId("string")
.build()
)
.fileSearch(
Assistant.ToolResources.FileSearch.builder()
.vectorStoreIds(listOf("string"))
.addVectorStoreId("string")
.build()
)
.build()
Expand Down Expand Up @@ -80,12 +78,12 @@ class AssistantTest {
Assistant.ToolResources.builder()
.codeInterpreter(
Assistant.ToolResources.CodeInterpreter.builder()
.fileIds(listOf("string"))
.addFileId("string")
.build()
)
.fileSearch(
Assistant.ToolResources.FileSearch.builder()
.vectorStoreIds(listOf("string"))
.addVectorStoreId("string")
.build()
)
.build()
Expand Down
32 changes: 14 additions & 18 deletions openai-java-core/src/test/kotlin/com/openai/models/BatchTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ class BatchTest {
.errorFileId("error_file_id")
.errors(
Batch.Errors.builder()
.data(
listOf(
BatchError.builder()
.code("code")
.line(0L)
.message("message")
.param("param")
.build()
)
.addData(
BatchError.builder()
.code("code")
.line(0L)
.message("message")
.param("param")
.build()
)
.object_("object")
.build()
Expand Down Expand Up @@ -64,15 +62,13 @@ class BatchTest {
assertThat(batch.errors())
.contains(
Batch.Errors.builder()
.data(
listOf(
BatchError.builder()
.code("code")
.line(0L)
.message("message")
.param("param")
.build()
)
.addData(
BatchError.builder()
.code("code")
.line(0L)
.message("message")
.param("param")
.build()
)
.object_("object")
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,35 @@ class BetaAssistantCreateParamsTest {
BetaAssistantCreateParams.ToolResources.builder()
.codeInterpreter(
BetaAssistantCreateParams.ToolResources.CodeInterpreter.builder()
.fileIds(listOf("string"))
.addFileId("string")
.build()
)
.fileSearch(
BetaAssistantCreateParams.ToolResources.FileSearch.builder()
.vectorStoreIds(listOf("string"))
.vectorStores(
listOf(
BetaAssistantCreateParams.ToolResources.FileSearch.VectorStore
.builder()
.chunkingStrategy(
FileChunkingStrategyParam
.ofAutoFileChunkingStrategyParam(
AutoFileChunkingStrategyParam.builder()
.type(
AutoFileChunkingStrategyParam.Type.AUTO
)
.build()
)
.addVectorStoreId("string")
.addVectorStore(
BetaAssistantCreateParams.ToolResources.FileSearch.VectorStore
.builder()
.chunkingStrategy(
FileChunkingStrategyParam.ofAutoFileChunkingStrategyParam(
AutoFileChunkingStrategyParam.builder()
.type(AutoFileChunkingStrategyParam.Type.AUTO)
.build()
)
.fileIds(listOf("string"))
.metadata(JsonValue.from(mapOf<String, Any>()))
.build()
)
)
.addFileId("string")
.metadata(JsonValue.from(mapOf<String, Any>()))
.build()
)
.build()
)
.build()
)
.tools(
listOf(
AssistantTool.ofCodeInterpreterTool(
CodeInterpreterTool.builder()
.type(CodeInterpreterTool.Type.CODE_INTERPRETER)
.build()
)
.addTool(
AssistantTool.ofCodeInterpreterTool(
CodeInterpreterTool.builder()
.type(CodeInterpreterTool.Type.CODE_INTERPRETER)
.build()
)
)
.topP(1.0)
Expand All @@ -87,44 +80,38 @@ class BetaAssistantCreateParamsTest {
BetaAssistantCreateParams.ToolResources.builder()
.codeInterpreter(
BetaAssistantCreateParams.ToolResources.CodeInterpreter.builder()
.fileIds(listOf("string"))
.addFileId("string")
.build()
)
.fileSearch(
BetaAssistantCreateParams.ToolResources.FileSearch.builder()
.vectorStoreIds(listOf("string"))
.vectorStores(
listOf(
BetaAssistantCreateParams.ToolResources.FileSearch
.VectorStore
.builder()
.chunkingStrategy(
FileChunkingStrategyParam
.ofAutoFileChunkingStrategyParam(
AutoFileChunkingStrategyParam.builder()
.type(
AutoFileChunkingStrategyParam.Type
.AUTO
)
.build()
)
)
.fileIds(listOf("string"))
.metadata(JsonValue.from(mapOf<String, Any>()))
.build()
)
.addVectorStoreId("string")
.addVectorStore(
BetaAssistantCreateParams.ToolResources.FileSearch.VectorStore
.builder()
.chunkingStrategy(
FileChunkingStrategyParam
.ofAutoFileChunkingStrategyParam(
AutoFileChunkingStrategyParam.builder()
.type(
AutoFileChunkingStrategyParam.Type.AUTO
)
.build()
)
)
.addFileId("string")
.metadata(JsonValue.from(mapOf<String, Any>()))
.build()
)
.build()
)
.build()
)
.tools(
listOf(
AssistantTool.ofCodeInterpreterTool(
CodeInterpreterTool.builder()
.type(CodeInterpreterTool.Type.CODE_INTERPRETER)
.build()
)
.addTool(
AssistantTool.ofCodeInterpreterTool(
CodeInterpreterTool.builder()
.type(CodeInterpreterTool.Type.CODE_INTERPRETER)
.build()
)
)
.topP(1.0)
Expand All @@ -148,30 +135,25 @@ class BetaAssistantCreateParamsTest {
BetaAssistantCreateParams.ToolResources.builder()
.codeInterpreter(
BetaAssistantCreateParams.ToolResources.CodeInterpreter.builder()
.fileIds(listOf("string"))
.addFileId("string")
.build()
)
.fileSearch(
BetaAssistantCreateParams.ToolResources.FileSearch.builder()
.vectorStoreIds(listOf("string"))
.vectorStores(
listOf(
BetaAssistantCreateParams.ToolResources.FileSearch.VectorStore
.builder()
.chunkingStrategy(
FileChunkingStrategyParam
.ofAutoFileChunkingStrategyParam(
AutoFileChunkingStrategyParam.builder()
.type(
AutoFileChunkingStrategyParam.Type.AUTO
)
.build()
)
.addVectorStoreId("string")
.addVectorStore(
BetaAssistantCreateParams.ToolResources.FileSearch.VectorStore
.builder()
.chunkingStrategy(
FileChunkingStrategyParam.ofAutoFileChunkingStrategyParam(
AutoFileChunkingStrategyParam.builder()
.type(AutoFileChunkingStrategyParam.Type.AUTO)
.build()
)
.fileIds(listOf("string"))
.metadata(JsonValue.from(mapOf<String, Any>()))
.build()
)
)
.addFileId("string")
.metadata(JsonValue.from(mapOf<String, Any>()))
.build()
)
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,21 @@ class BetaAssistantUpdateParamsTest {
BetaAssistantUpdateParams.ToolResources.builder()
.codeInterpreter(
BetaAssistantUpdateParams.ToolResources.CodeInterpreter.builder()
.fileIds(listOf("string"))
.addFileId("string")
.build()
)
.fileSearch(
BetaAssistantUpdateParams.ToolResources.FileSearch.builder()
.vectorStoreIds(listOf("string"))
.addVectorStoreId("string")
.build()
)
.build()
)
.tools(
listOf(
AssistantTool.ofCodeInterpreterTool(
CodeInterpreterTool.builder()
.type(CodeInterpreterTool.Type.CODE_INTERPRETER)
.build()
)
.addTool(
AssistantTool.ofCodeInterpreterTool(
CodeInterpreterTool.builder()
.type(CodeInterpreterTool.Type.CODE_INTERPRETER)
.build()
)
)
.topP(1.0)
Expand All @@ -70,23 +68,21 @@ class BetaAssistantUpdateParamsTest {
BetaAssistantUpdateParams.ToolResources.builder()
.codeInterpreter(
BetaAssistantUpdateParams.ToolResources.CodeInterpreter.builder()
.fileIds(listOf("string"))
.addFileId("string")
.build()
)
.fileSearch(
BetaAssistantUpdateParams.ToolResources.FileSearch.builder()
.vectorStoreIds(listOf("string"))
.addVectorStoreId("string")
.build()
)
.build()
)
.tools(
listOf(
AssistantTool.ofCodeInterpreterTool(
CodeInterpreterTool.builder()
.type(CodeInterpreterTool.Type.CODE_INTERPRETER)
.build()
)
.addTool(
AssistantTool.ofCodeInterpreterTool(
CodeInterpreterTool.builder()
.type(CodeInterpreterTool.Type.CODE_INTERPRETER)
.build()
)
)
.topP(1.0)
Expand All @@ -110,12 +106,12 @@ class BetaAssistantUpdateParamsTest {
BetaAssistantUpdateParams.ToolResources.builder()
.codeInterpreter(
BetaAssistantUpdateParams.ToolResources.CodeInterpreter.builder()
.fileIds(listOf("string"))
.addFileId("string")
.build()
)
.fileSearch(
BetaAssistantUpdateParams.ToolResources.FileSearch.builder()
.vectorStoreIds(listOf("string"))
.addVectorStoreId("string")
.build()
)
.build()
Expand Down
Loading