zxs1633079383 commented on code in PR #870:
URL: https://github.com/apache/flink-agents/pull/870#discussion_r3618992924


##########
api/src/main/java/org/apache/flink/agents/api/embedding/model/BaseEmbeddingModelSetup.java:
##########
@@ -104,9 +104,18 @@ public float[] embed(String text) {
     }
 
     public float[] embed(String text, Map<String, Object> parameters) {
+        return embedWithUsage(text, parameters).getEmbeddings();

Review Comment:
   Updated in 0dc947f.
   
   `BaseEmbeddingModelSetup.embed(...)` now resolves the setup parameters and 
calls `getConnection().embed(...)` directly. `embedWithUsage(...)` remains on 
the separate usage-aware path. The Python `BaseEmbeddingModelSetup.embed(...)` 
now follows the same dispatch rule.
   
   I added Java and Python regressions where `embed(...)` and 
`embedWithUsage(...)` intentionally return different embeddings, proving that 
the ordinary API preserves the existing provider/subclass override point.



##########
python/flink_agents/api/embedding_models/embedding_model.py:
##########
@@ -120,6 +145,12 @@ def embed(
             A list of floating-point numbers representing the embedding vector.
             The dimension of the vector depends on the specific embedding 
model used.
         """
+        return self.embed_with_usage(text, **kwargs).embeddings
+
+    def embed_with_usage(

Review Comment:
   Updated in 0dc947f.
   
   I added explicit bridges for `embedWithUsage(...)` / `embed_with_usage(...)` 
on both setup and connection wrappers.
   
   For Java -> Python, the bridge calls 
`python_java_utils.call_embedding_with_usage`, which converts the Python 
`EmbeddingResult` dataclass into a Pemja-safe map containing only embeddings, 
token-usage maps, and primitives before Java reconstructs `EmbeddingResult`. 
This avoids relying on Pemja to expose dataclass attributes. For Python -> 
Java, both Java resource wrappers now call Java `embedWithUsage(...)` directly 
and convert its result back to the Python dataclass.
   
   Coverage now includes Java setup/connection wrapper conversions, Python 
Java-wrapper conversions, and the existing Java/Python resource-cross-language 
agents exercise the single and batch usage APIs.



-- 
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]

Reply via email to