xintongsong commented on code in PR #427:
URL: https://github.com/apache/flink-agents/pull/427#discussion_r2681522552
##########
runtime/src/main/java/org/apache/flink/agents/runtime/python/utils/JavaResourceAdapter.java:
##########
@@ -121,4 +122,15 @@ public ChatMessage fromPythonChatMessage(Object
pythonChatMessage) {
chatMessage.setRole(MessageRole.fromValue(roleValue));
return chatMessage;
}
+
+
+ /**
+ * Retrieves a Java tool by name. This method is intended for use by the
Python interpreter.
+ *
+ * @param name the name of the tool to retrieve
+ * @return the tool
+ */
+ public Tool fromToolName(String name) throws Exception {
Review Comment:
I'd suggest the name `getTool`, similar to `getResource` except that the
type is already known.
##########
runtime/src/main/java/org/apache/flink/agents/runtime/operator/ActionExecutionOperator.java:
##########
@@ -576,17 +579,25 @@ private void initPythonEnvironment() throws Exception {
pythonRunnerContext =
new PythonRunnerContextImpl(
this.metricGroup, this::checkMailboxThread,
this.agentPlan);
+
+ javaResourceAdapter =
+ new JavaResourceAdapter(
+ (String anotherName, ResourceType anotherType) -> {
+ try {
+ return agentPlan.getResource(anotherName,
anotherType);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ },
Review Comment:
Minor: Le't make this a method of ActionExecutionOperator, and use
`this::getResource` here.
##########
runtime/src/main/java/org/apache/flink/agents/runtime/python/utils/JavaResourceAdapter.java:
##########
@@ -121,4 +122,15 @@ public ChatMessage fromPythonChatMessage(Object
pythonChatMessage) {
chatMessage.setRole(MessageRole.fromValue(roleValue));
return chatMessage;
}
+
+
+ /**
+ * Retrieves a Java tool by name. This method is intended for use by the
Python interpreter.
+ *
+ * @param name the name of the tool to retrieve
+ * @return the tool
+ */
+ public Tool fromToolName(String name) throws Exception {
Review Comment:
Why not just use `getResource`?
--
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]