You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "letaoj (via GitHub)" <gi...@apache.org> on 2025/08/05 18:06:27 UTC

[PR] [plan][runtime][java] Introduce Resource and Resource Provider in java [flink-agents]

letaoj opened a new pull request, #91:
URL: https://github.com/apache/flink-agents/pull/91

   <!--
   * Thank you very much for contributing to Flink Agents.
   * Please add the relevant components in the PR title. E.g., [api], [runtime], [java], [python], [hotfix], etc.
   -->
   
   <!-- Please link the PR to the relevant issue(s). Hotfix doesn't need this. -->
   Linked issue: #69 
   
   ### Purpose of change
   
   <!-- What is the purpose of this change? -->
   Introduce resource and resource provider concept in java to mimic the same behavior in python. This is the first step to introduce Tool, chat_model and prompt.
   
   ### Tests
   
   <!-- How is this change verified? -->
   Unit test added, however some of the code are not covered as we only have base class that is abstract which can't be instantiate for use.
   
   ### API
   
   <!-- Does this change touches any public APIs? -->
   Added resource and resource provider in java
   
   ### Documentation
   
   <!-- Should this change be covered by the user documentation?-->
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [plan][runtime][java] Introduce Resource and Resource Provider in java [flink-agents]

Posted by "xintongsong (via GitHub)" <gi...@apache.org>.
xintongsong merged PR #91:
URL: https://github.com/apache/flink-agents/pull/91


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [plan][runtime][java] Introduce Resource and Resource Provider in java [flink-agents]

Posted by "letaoj (via GitHub)" <gi...@apache.org>.
letaoj commented on PR #91:
URL: https://github.com/apache/flink-agents/pull/91#issuecomment-3168780117

   @xintongsong I used UI to actually merge the change because I saw there is a conflict between my commit and main branch. I've updated the PR with clean rebased git history. 


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [plan][runtime][java] Introduce Resource and Resource Provider in java [flink-agents]

Posted by "letaoj (via GitHub)" <gi...@apache.org>.
letaoj commented on code in PR #91:
URL: https://github.com/apache/flink-agents/pull/91#discussion_r2258997561


##########
api/src/main/java/org/apache/flink/agents/api/Resource.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.agents.api;
+
+import java.io.Serializable;
+import java.util.function.BiFunction;
+
+/**
+ * Base interface for all kinds of resources, including chat models, tools, prompts and so on.
+ *
+ * <p>Resources are components that can be used by agents during action execution.
+ */
+public interface Resource extends Serializable {

Review Comment:
   Hi @wenjin272 Thank you for the review. I will update the PR to reflect the concept described in this comment. 



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [plan][runtime][java] Introduce Resource and Resource Provider in java [flink-agents]

Posted by "istavrak (via GitHub)" <gi...@apache.org>.
istavrak commented on code in PR #91:
URL: https://github.com/apache/flink-agents/pull/91#discussion_r2255179255


##########
api/src/main/java/org/apache/flink/agents/api/resource/ResourceType.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.agents.api.resource;
+
+/**
+ * Type enum of resource.
+ *
+ * <p>Currently, only support chat models and tools.
+ */
+public enum ResourceType {
+    CHAT_MODEL("chat_model"),
+    TOOL("tool");
+    // EMBEDDING_MODEL("embedding_model"),

Review Comment:
   NIT: We may want to remove the commented out enums, as at the moment of update in the future the maintainer will need to check the Python implementation anyhow.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [plan][runtime][java] Introduce Resource and Resource Provider in java [flink-agents]

Posted by "xintongsong (via GitHub)" <gi...@apache.org>.
xintongsong commented on PR #91:
URL: https://github.com/apache/flink-agents/pull/91#issuecomment-3167120845

   Hi @letaoj,
   The PR also looks good to me. However, it cannot be merged due to conflicts. I think it's because you have used `git merge` to adapt latest changes from the main branch. Please use `git rebase` instead.


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [plan][runtime][java] Introduce Resource and Resource Provider in java [flink-agents]

Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on PR #91:
URL: https://github.com/apache/flink-agents/pull/91#issuecomment-3166452170

   LGTM, please take a look at your convenience @xintongsong.


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [plan][runtime][java] Introduce Resource and Resource Provider in java [flink-agents]

Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on code in PR #91:
URL: https://github.com/apache/flink-agents/pull/91#discussion_r2256489331


##########
api/src/main/java/org/apache/flink/agents/api/Resource.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.agents.api;
+
+import java.io.Serializable;
+import java.util.function.BiFunction;
+
+/**
+ * Base interface for all kinds of resources, including chat models, tools, prompts and so on.
+ *
+ * <p>Resources are components that can be used by agents during action execution.
+ */
+public interface Resource extends Serializable {

Review Comment:
   In python implementation, there are two type of Resource:
   1. Resource which is not json serializable, link ChatModel, for it may contain some fields which are not json serializable.
   2. SerializableResource which is json serializable, link function tool.
   
   For Resource we construct it in runtime, and for SerializableResource we can get or deserialize it in runtime. 
   
   In currently implementation, for there is no resource implementation which is not json serializable, only provide resource is enough, but for clarity of semantics, I think may be we can provide distinction at the beginning
   



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [plan][runtime][java] Introduce Resource and Resource Provider in java [flink-agents]

Posted by "letaoj (via GitHub)" <gi...@apache.org>.
letaoj commented on code in PR #91:
URL: https://github.com/apache/flink-agents/pull/91#discussion_r2255292849


##########
api/src/main/java/org/apache/flink/agents/api/resource/ResourceType.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.agents.api.resource;
+
+/**
+ * Type enum of resource.
+ *
+ * <p>Currently, only support chat models and tools.
+ */
+public enum ResourceType {
+    CHAT_MODEL("chat_model"),
+    TOOL("tool");
+    // EMBEDDING_MODEL("embedding_model"),

Review Comment:
   removed.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org