wenjin272 commented on code in PR #1126:
URL: https://github.com/apache/flink-agents/pull/1126#discussion_r4036158920
##########
docs/content/docs/development/embedding_models.md:
##########
@@ -453,28 +452,106 @@ class MyAgent(Agent):
encoding_format="float"
)
```
+{{< /tab >}}
+
+{{< tab "Java" >}}
+```java
+public class MyAgent extends Agent {
+
+ @EmbeddingModelConnection
+ public static ResourceDescriptor openaiConnection() {
+ return
ResourceDescriptor.Builder.newBuilder(ResourceName.EmbeddingModel.OPENAI_CONNECTION)
+ .addInitialArgument("api_key", System.getenv("OPENAI_API_KEY"))
+ .addInitialArgument("request_timeout", 30)
+ .addInitialArgument("max_retries", 3)
+ .build();
+ }
+
+ @EmbeddingModelSetup
+ public static ResourceDescriptor openaiEmbedding() {
+ return
ResourceDescriptor.Builder.newBuilder(ResourceName.EmbeddingModel.OPENAI_SETUP)
+ .addInitialArgument("connection", "openaiConnection")
+ .addInitialArgument("model", "text-embedding-3-small")
+ .addInitialArgument("dimensions", 512)
+ .build();
+ }
+
+ ...
+}
+```
+{{< /tab >}}
+
+{{< /tabs >}}
#### OpenAIEmbeddingModelConnection Parameters
+{{< tabs "OpenAIEmbeddingModelConnection Parameters" >}}
+
+{{< tab "Python" >}}
+
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
-| `api_key` | str | Required | OpenAI API key for authentication |
+| `api_key` | str | Required | OpenAI API key for authentication; a blank key
is passed through to the SDK for unauthenticated OpenAI-compatible servers (the
Java connection rejects a blank key) |
| `base_url` | str | `"https://api.openai.com/v1"` | OpenAI API base URL |
-| `request_timeout` | float | `30.0` | HTTP request timeout in seconds |
+| `request_timeout` | float | `30.0` | HTTP request timeout in seconds; `0`
disables the timeout |
| `max_retries` | int | `3` | Maximum number of retry attempts |
-| `organization` | str | None | Optional organization ID |
-| `project` | str | None | Optional project ID |
+| `organization` | str | None | Optional organization ID; when unset or blank
the Python SDK may read `OPENAI_ORG_ID` from the environment (the Java
connection sends no organization) |
+| `project` | str | None | Optional project ID; when unset or blank the Python
SDK may read `OPENAI_PROJECT_ID` from the environment (the Java connection
sends no project) |
+
+{{< /tab >}}
+
+{{< tab "Java" >}}
+
+| Parameter | Type | Default | Description |
+|-----------|------|---------|-------------|
+| `api_key` | String | Required | OpenAI API key for authentication |
+| `base_url` | String | `"https://api.openai.com/v1"` | OpenAI API base URL |
+| `request_timeout` | Number | `30` | HTTP request timeout in seconds; `0`
disables the timeout |
+| `max_retries` | Number | `3` | Maximum number of retry attempts, a
non-negative integer |
+| `organization` | String | None | Optional organization ID |
+| `project` | String | None | Optional project ID |
+
+{{< /tab >}}
+
+{{< /tabs >}}
#### OpenAIEmbeddingModelSetup Parameters
+{{< tabs "OpenAIEmbeddingModelSetup Parameters" >}}
+
+{{< tab "Python" >}}
+
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `connection` | str | Required | Reference to connection method name |
| `model` | str | Required | OpenAI embedding model name |
-| `encoding_format` | str | `"float"` | Return format ("float" or "base64") |
+| `encoding_format` | str | `"float"` | Wire format, `"float"` or `"base64"`;
base64 responses are decoded to floats |
| `dimensions` | int | None | Output dimensions (text-embedding-3 models only)
|
| `user` | str | None | End-user identifier for monitoring |
-| `additional_kwargs` | dict | `{}` | Additional parameters for the OpenAI
embeddings API |
+| `additional_kwargs` | dict | `{}` | Extra request body properties sent with
every embeddings request; keys may not be `model`, `input`, `encoding_format`,
`dimensions` or `user`. A per-call `additional_kwargs` replaces this map |
+
+Since 0.4, `additional_kwargs` entries are sent to the API (earlier releases
dropped them), an entry that repeats a typed field fails validation instead of
overriding it (set the typed argument instead), `model_kwargs` nests them under
an `additional_kwargs` key instead of spreading them, and `dimensions` must be
an integer.
Review Comment:
Since 0.x does not guarantee API compatibility, could we keep this section
focused on the current contract and remove the implementation-history wording
(`Since 0.4`, `earlier releases`, and the `model_kwargs` shape change)? If an
upgrade note is still useful, release notes would be a better place for it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]