Skip to content

Commit

Permalink
chore: simplify examples involving lists (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Jan 15, 2025
1 parent 2c45caf commit 2c5436e
Show file tree
Hide file tree
Showing 60 changed files with 1,874 additions and 2,438 deletions.
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

0 comments on commit 2c5436e

Please sign in to comment.