GreatEugenius commented on code in PR #459:
URL: https://github.com/apache/flink-agents/pull/459#discussion_r2719912101
##########
docs/content/docs/development/chat_models.md:
##########
@@ -680,6 +680,153 @@ Some popular options include:
Model availability and specifications may change. Always check the official
DashScope documentation for the latest information before implementing in
production.
{{< /hint >}}
+## Using Cross-Language Providers
+
+Flink Agents supports cross-language chat model integration, allowing you to
use chat models implemented in one language (Java or Python) from agents
written in the other language. This is particularly useful when a chat model
provider is only available in one language (e.g., Tongyi is currently
Python-only).
+
+{{< hint warning >}}
+**Limitations:**
+- Cross-language resources are currently supported only when [running in
Flink]({{< ref "docs/operations/deployment#run-in-flink" >}}), not in local
development mode
+- Complex object serialization between languages may have limitations
+{{< /hint >}}
+
+### How To Use
+
+To leverage chat model supports provided in a different language, you need to
declare the resource within a built-in cross-language wrapper, and specify the
target provider as an argument:
+
+- **Using Java chat models in Python**: Use
`Constant.JAVA_CHAT_MODEL_CONNECTION` and `Constant.JAVA_CHAT_MODEL_SETUP`,
specifying the Java provider class via the `java_clazz` parameter
+- **Using Python chat models in Java**: Use
`Constant.PYTHON_CHAT_MODEL_CONNECTION` and `Constant.PYTHON_CHAT_MODEL_SETUP`,
specifying the Python provider via `module` and `clazz` parameters
+
+
+
+### Usage Example
+
+{{< tabs "Cross-Language Chat Model Usage Example" >}}
+
+{{< tab "Using Java Chat Model in Python" >}}
+```python
+class MyAgent(Agent):
+
+ @chat_model_connection
+ @staticmethod
+ def java_chat_model_connection() -> ResourceDescriptor:
+ # In pure Java, the equivalent ResourceDescriptor would be:
+ # ResourceDescriptor.Builder
+ # .newBuilder(Constant.OllamaChatModelConnection)
+ # .addInitialArgument("endpoint", "http://localhost:11434")
+ # .addInitialArgument("requestTimeout", 120)
+ # .build();
+ return ResourceDescriptor(
+ clazz=Constant.JAVA_CHAT_MODEL_CONNECTION,
+
java_clazz="org.apache.flink.agents.integrations.chatmodels.ollama.OllamaChatModelConnection",
Review Comment:
Track the issue at: https://github.com/apache/flink-agents/issues/469
--
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]