diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIClient.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIClient.java index 7d441596653d..2315e88e025f 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIClient.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIClient.java @@ -30,16 +30,16 @@ import com.azure.core.util.IterableStream; import com.azure.core.util.logging.ClientLogger; import com.azure.core.util.polling.SyncPoller; -import reactor.core.Exceptions; -import reactor.core.publisher.Flux; - import java.io.IOException; import java.io.UncheckedIOException; import java.nio.ByteBuffer; +import reactor.core.Exceptions; +import reactor.core.publisher.Flux; /** Initializes a new instance of the synchronous OpenAIClient type. */ @ServiceClient(builder = OpenAIClientBuilder.class) public final class OpenAIClient { + private static final ClientLogger LOGGER = new ClientLogger(OpenAIClient.class); @Generated private final OpenAIClientImpl serviceClient; @@ -481,22 +481,23 @@ public IterableStream getChatCompletionsStream( public ImageResponse getImages(ImageGenerationOptions imageGenerationOptions) { RequestOptions requestOptions = new RequestOptions(); BinaryData imageGenerationOptionsBinaryData = BinaryData.fromObject(imageGenerationOptions); - if (openAIServiceClient != null) { return openAIServiceClient - .generateImageWithResponse(imageGenerationOptionsBinaryData, requestOptions) - .getValue() - .toObject(ImageResponse.class); + .generateImageWithResponse(imageGenerationOptionsBinaryData, requestOptions) + .getValue() + .toObject(ImageResponse.class); } else { - // TODO: Currently, we use async client block() to avoid a unknown LRO status "notRunning" which Azure Core will + // TODO: Currently, we use async client block() to avoid a unknown LRO status "notRunning" which Azure Core + // will // fix the issue in August release and we will reuse the method // "SyncPoller beginBeginAzureBatchImageGeneration()" after. try { - return this.serviceClient.beginBeginAzureBatchImageGenerationAsync(imageGenerationOptionsBinaryData, - requestOptions) - .last() - .flatMap(it -> it.getFinalResult()) - .map(it -> it.toObject(ImageOperationResponse.class).getResult()).block(); + return this.serviceClient + .beginBeginAzureBatchImageGenerationAsync(imageGenerationOptionsBinaryData, requestOptions) + .last() + .flatMap(it -> it.getFinalResult()) + .map(it -> it.toObject(ImageOperationResponse.class).getResult()) + .block(); } catch (Exception e) { Throwable unwrapped = Exceptions.unwrap(e); if (unwrapped instanceof RuntimeException) { diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/implementation/OpenAIClientImpl.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/implementation/OpenAIClientImpl.java index ff4217c2cdd5..8ba1443d0418 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/implementation/OpenAIClientImpl.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/implementation/OpenAIClientImpl.java @@ -483,7 +483,7 @@ public Response getEmbeddingsWithResponse( *
{@code
      * {
      *     id: String (Required)
-     *     created: int (Required)
+     *     created: long (Required)
      *     prompt_annotations (Optional): [
      *          (Optional){
      *             prompt_index: int (Required)
@@ -596,7 +596,7 @@ public Mono> getCompletionsWithResponseAsync(
      * 
{@code
      * {
      *     id: String (Required)
-     *     created: int (Required)
+     *     created: long (Required)
      *     prompt_annotations (Optional): [
      *          (Optional){
      *             prompt_index: int (Required)
@@ -680,7 +680,7 @@ public Response getCompletionsWithResponse(
      *     messages (Required): [
      *          (Required){
      *             role: String(system/assistant/user/function) (Required)
-     *             content: String (Optional)
+     *             content: String (Required)
      *             name: String (Optional)
      *             function_call (Optional): {
      *                 name: String (Required)
@@ -719,12 +719,12 @@ public Response getCompletionsWithResponse(
      * 
{@code
      * {
      *     id: String (Required)
-     *     created: int (Required)
+     *     created: long (Required)
      *     choices (Required): [
      *          (Required){
      *             message (Optional): {
      *                 role: String(system/assistant/user/function) (Required)
-     *                 content: String (Optional)
+     *                 content: String (Required)
      *                 name: String (Optional)
      *                 function_call (Optional): {
      *                     name: String (Required)
@@ -799,7 +799,7 @@ public Mono> getChatCompletionsWithResponseAsync(
      *     messages (Required): [
      *          (Required){
      *             role: String(system/assistant/user/function) (Required)
-     *             content: String (Optional)
+     *             content: String (Required)
      *             name: String (Optional)
      *             function_call (Optional): {
      *                 name: String (Required)
@@ -838,12 +838,12 @@ public Mono> getChatCompletionsWithResponseAsync(
      * 
{@code
      * {
      *     id: String (Required)
-     *     created: int (Required)
+     *     created: long (Required)
      *     choices (Required): [
      *          (Required){
      *             message (Optional): {
      *                 role: String(system/assistant/user/function) (Required)
-     *                 content: String (Optional)
+     *                 content: String (Required)
      *                 name: String (Optional)
      *                 function_call (Optional): {
      *                     name: String (Required)
diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatCompletions.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatCompletions.java
index bd9c76f08c64..130e19328391 100644
--- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatCompletions.java
+++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatCompletions.java
@@ -7,6 +7,9 @@
 import com.azure.core.annotation.Immutable;
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
+import java.time.Instant;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
 import java.util.List;
 
 /**
@@ -39,27 +42,6 @@ public final class ChatCompletions {
     @JsonProperty(value = "usage")
     private CompletionsUsage usage;
 
-    /**
-     * Creates an instance of ChatCompletions class.
-     *
-     * @param id the id value to set.
-     * @param createdAt the createdAt value to set.
-     * @param choices the choices value to set.
-     * @param usage the usage value to set.
-     */
-    @Generated
-    @JsonCreator
-    private ChatCompletions(
-            @JsonProperty(value = "id") String id,
-            @JsonProperty(value = "created") int createdAt,
-            @JsonProperty(value = "choices") List choices,
-            @JsonProperty(value = "usage") CompletionsUsage usage) {
-        this.id = id;
-        this.createdAt = createdAt;
-        this.choices = choices;
-        this.usage = usage;
-    }
-
     /**
      * Get the id property: A unique identifier associated with this chat completions response.
      *
@@ -99,7 +81,7 @@ public CompletionsUsage getUsage() {
      */
     @Generated
     @JsonProperty(value = "created")
-    private int createdAt;
+    private long createdAt;
 
     /**
      * Get the createdAt property: The first timestamp associated with generation activity for this completions
@@ -108,8 +90,8 @@ public CompletionsUsage getUsage() {
      * @return the createdAt value.
      */
     @Generated
-    public int getCreatedAt() {
-        return this.createdAt;
+    public OffsetDateTime getCreatedAt() {
+        return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.createdAt), ZoneOffset.UTC);
     }
 
     /*
@@ -130,4 +112,30 @@ public int getCreatedAt() {
     public List getPromptFilterResults() {
         return this.promptFilterResults;
     }
+
+    /**
+     * Creates an instance of ChatCompletions class.
+     *
+     * @param id the id value to set.
+     * @param createdAt the createdAt value to set.
+     * @param choices the choices value to set.
+     * @param usage the usage value to set.
+     */
+    @Generated
+    private ChatCompletions(String id, OffsetDateTime createdAt, List choices, CompletionsUsage usage) {
+        this.id = id;
+        this.createdAt = createdAt.toEpochSecond();
+        this.choices = choices;
+        this.usage = usage;
+    }
+
+    @Generated
+    @JsonCreator
+    private ChatCompletions(
+            @JsonProperty(value = "id") String id,
+            @JsonProperty(value = "created") long createdAt,
+            @JsonProperty(value = "choices") List choices,
+            @JsonProperty(value = "usage") CompletionsUsage usage) {
+        this(id, OffsetDateTime.ofInstant(Instant.ofEpochSecond(createdAt), ZoneOffset.UTC), choices, usage);
+    }
 }
diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatMessage.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatMessage.java
index 2594743f63f7..4207c220a552 100644
--- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatMessage.java
+++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatMessage.java
@@ -26,17 +26,6 @@ public final class ChatMessage {
     @JsonProperty(value = "content")
     private String content;
 
-    /**
-     * Creates an instance of ChatMessage class.
-     *
-     * @param role the role value to set.
-     */
-    @Generated
-    @JsonCreator
-    public ChatMessage(@JsonProperty(value = "role") ChatRole role) {
-        this.role = role;
-    }
-
     /**
      * Get the role property: The role associated with this message payload.
      *
@@ -57,18 +46,6 @@ public String getContent() {
         return this.content;
     }
 
-    /**
-     * Set the content property: The text associated with this message payload.
-     *
-     * @param content the content value to set.
-     * @return the ChatMessage object itself.
-     */
-    @Generated
-    public ChatMessage setContent(String content) {
-        this.content = content;
-        return this;
-    }
-
     /*
      * The name of the author of this message. `name` is required if role is `function`, and it should be the name of
      * the
@@ -136,4 +113,17 @@ public ChatMessage setFunctionCall(FunctionCall functionCall) {
         this.functionCall = functionCall;
         return this;
     }
+
+    /**
+     * Creates an instance of ChatMessage class.
+     *
+     * @param role the role value to set.
+     * @param content the content value to set.
+     */
+    @Generated
+    @JsonCreator
+    public ChatMessage(@JsonProperty(value = "role") ChatRole role, @JsonProperty(value = "content") String content) {
+        this.role = role;
+        this.content = content;
+    }
 }
diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/Completions.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/Completions.java
index 51a9faa84c1c..3b190350fba9 100644
--- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/Completions.java
+++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/Completions.java
@@ -7,6 +7,9 @@
 import com.azure.core.annotation.Immutable;
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
+import java.time.Instant;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
 import java.util.List;
 
 /**
@@ -23,14 +26,6 @@ public final class Completions {
     @JsonProperty(value = "id")
     private String id;
 
-    /*
-     * The first timestamp associated with generation activity for this completions response,
-     * represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970.
-     */
-    @Generated
-    @JsonProperty(value = "created")
-    private int created;
-
     /*
      * The collection of completions choices associated with this completions response.
      * Generally, `n` choices are generated per provided prompt with a default value of 1.
@@ -47,27 +42,6 @@ public final class Completions {
     @JsonProperty(value = "usage")
     private CompletionsUsage usage;
 
-    /**
-     * Creates an instance of Completions class.
-     *
-     * @param id the id value to set.
-     * @param created the created value to set.
-     * @param choices the choices value to set.
-     * @param usage the usage value to set.
-     */
-    @Generated
-    @JsonCreator
-    private Completions(
-            @JsonProperty(value = "id") String id,
-            @JsonProperty(value = "created") int created,
-            @JsonProperty(value = "choices") List choices,
-            @JsonProperty(value = "usage") CompletionsUsage usage) {
-        this.id = id;
-        this.created = created;
-        this.choices = choices;
-        this.usage = usage;
-    }
-
     /**
      * Get the id property: A unique identifier associated with this completions response.
      *
@@ -78,17 +52,6 @@ public String getId() {
         return this.id;
     }
 
-    /**
-     * Get the created property: The first timestamp associated with generation activity for this completions response,
-     * represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970.
-     *
-     * @return the created value.
-     */
-    @Generated
-    public int getCreated() {
-        return this.created;
-    }
-
     /**
      * Get the choices property: The collection of completions choices associated with this completions response.
      * Generally, `n` choices are generated per provided prompt with a default value of 1. Token limits and other
@@ -130,4 +93,49 @@ public CompletionsUsage getUsage() {
     public List getPromptFilterResults() {
         return this.promptFilterResults;
     }
+
+    /*
+     * The first timestamp associated with generation activity for this completions response,
+     * represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970.
+     */
+    @Generated
+    @JsonProperty(value = "created")
+    private long createdAt;
+
+    /**
+     * Creates an instance of Completions class.
+     *
+     * @param id the id value to set.
+     * @param createdAt the createdAt value to set.
+     * @param choices the choices value to set.
+     * @param usage the usage value to set.
+     */
+    @Generated
+    private Completions(String id, OffsetDateTime createdAt, List choices, CompletionsUsage usage) {
+        this.id = id;
+        this.createdAt = createdAt.toEpochSecond();
+        this.choices = choices;
+        this.usage = usage;
+    }
+
+    @Generated
+    @JsonCreator
+    private Completions(
+            @JsonProperty(value = "id") String id,
+            @JsonProperty(value = "created") long createdAt,
+            @JsonProperty(value = "choices") List choices,
+            @JsonProperty(value = "usage") CompletionsUsage usage) {
+        this(id, OffsetDateTime.ofInstant(Instant.ofEpochSecond(createdAt), ZoneOffset.UTC), choices, usage);
+    }
+
+    /**
+     * Get the createdAt property: The first timestamp associated with generation activity for this completions
+     * response, represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970.
+     *
+     * @return the createdAt value.
+     */
+    @Generated
+    public OffsetDateTime getCreatedAt() {
+        return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.createdAt), ZoneOffset.UTC);
+    }
 }
diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/FunctionDefinition.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/FunctionDefinition.java
new file mode 100644
index 000000000000..379a5adb4eba
--- /dev/null
+++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/FunctionDefinition.java
@@ -0,0 +1,105 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+
+package com.azure.ai.openai.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.core.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * The definition of a caller-specified function that chat completions may invoke in response to matching user input.
+ */
+@Fluent
+public final class FunctionDefinition {
+    /*
+     * The name of the function to be called.
+     */
+    @Generated
+    @JsonProperty(value = "name")
+    private String name;
+
+    /*
+     * A description of what the function does. The model will use this description when selecting the function and
+     * interpreting its parameters.
+     */
+    @Generated
+    @JsonProperty(value = "description")
+    private String description;
+
+    /*
+     * The parameters the functions accepts, described as a JSON Schema object.
+     */
+    @Generated
+    @JsonProperty(value = "parameters")
+    private Object parameters;
+
+    /**
+     * Creates an instance of FunctionDefinition class.
+     *
+     * @param name the name value to set.
+     */
+    @Generated
+    @JsonCreator
+    public FunctionDefinition(@JsonProperty(value = "name") String name) {
+        this.name = name;
+    }
+
+    /**
+     * Get the name property: The name of the function to be called.
+     *
+     * @return the name value.
+     */
+    @Generated
+    public String getName() {
+        return this.name;
+    }
+
+    /**
+     * Get the description property: A description of what the function does. The model will use this description when
+     * selecting the function and interpreting its parameters.
+     *
+     * @return the description value.
+     */
+    @Generated
+    public String getDescription() {
+        return this.description;
+    }
+
+    /**
+     * Set the description property: A description of what the function does. The model will use this description when
+     * selecting the function and interpreting its parameters.
+     *
+     * @param description the description value to set.
+     * @return the FunctionDefinition object itself.
+     */
+    @Generated
+    public FunctionDefinition setDescription(String description) {
+        this.description = description;
+        return this;
+    }
+
+    /**
+     * Get the parameters property: The parameters the functions accepts, described as a JSON Schema object.
+     *
+     * @return the parameters value.
+     */
+    @Generated
+    public Object getParameters() {
+        return this.parameters;
+    }
+
+    /**
+     * Set the parameters property: The parameters the functions accepts, described as a JSON Schema object.
+     *
+     * @param parameters the parameters value to set.
+     * @return the FunctionDefinition object itself.
+     */
+    @Generated
+    public FunctionDefinition setParameters(Object parameters) {
+        this.parameters = parameters;
+        return this;
+    }
+}
diff --git a/sdk/openai/azure-ai-openai/tsp-location.yaml b/sdk/openai/azure-ai-openai/tsp-location.yaml
index 37564548546f..1a86107809ea 100644
--- a/sdk/openai/azure-ai-openai/tsp-location.yaml
+++ b/sdk/openai/azure-ai-openai/tsp-location.yaml
@@ -1,5 +1,5 @@
-directory: specification/cognitiveservices/OpenAI.Inference
-additionalDirectories:
-    - specification/cognitiveservices/OpenAI.Authoring
-commit: c09314bffaffd8fb6227e4b906aa35f41d2d7f33
 repo: Azure/azure-rest-api-specs
+additionalDirectories: []
+commit: 34327f0b5e323feb8e3c8a9d8ddb69ccd70452f0
+directory: specification/cognitiveservices/OpenAI.Inference
+