wenjin272 commented on code in PR #94: URL: https://github.com/apache/flink-agents/pull/94#discussion_r2281170622
########## api/src/main/java/org/apache/flink/agents/api/util/StringUtils.java: ########## @@ -0,0 +1,79 @@ +/* + * 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.util; + +/** Utility methods for String operations in the Flink Agents framework. */ +public final class StringUtils { Review Comment: Class 'StringUtils' is never used. ########## api/src/main/java/org/apache/flink/agents/api/chat/messages/ChatMessage.java: ########## @@ -0,0 +1,173 @@ +/* + * 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.chat.messages; + +import org.apache.flink.agents.api.resource.Resource; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * Chat message class that represents all message types (user, system, assistant, tool) with + * different roles + */ +public class ChatMessage implements Message { + + /** The key for the message type in the metadata. */ + public static final String MESSAGE_TYPE = "messageType"; + + private MessageRole role; + private String content; + private List<Map<String, Object>> toolCalls; + private Map<String, Object> extraArgs; + + /** Default constructor with USER role */ + public ChatMessage() { + this.role = MessageRole.USER; Review Comment: The default role could be System to be aligned with python implementation. ########## api/src/main/java/org/apache/flink/agents/api/tools/BaseTool.java: ########## @@ -0,0 +1,62 @@ +/* + * 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.tools; + +import org.apache.flink.agents.api.resource.ResourceType; +import org.apache.flink.agents.api.resource.SerializableResource; + +/** + * Simplified base class for all tools. Focus on essential tool functionality without + * overcomplicated features. + */ +public abstract class BaseTool extends SerializableResource { + + protected final ToolMetadata metadata; + + protected BaseTool(ToolMetadata metadata) { + this.metadata = java.util.Objects.requireNonNull(metadata, "metadata cannot be null"); + } + + /** Get the metadata of this tool. */ + public final ToolMetadata getMetadata() { + return metadata; + } + + /** Return resource type of class. */ + @Override + public final ResourceType getResourceType() { Review Comment: Maybe this could be static method ########## api/src/main/java/org/apache/flink/agents/api/chat/messages/ToolCall.java: ########## @@ -0,0 +1,85 @@ +/* + * 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.chat.messages; + +import java.util.Objects; + +public class ToolCall { Review Comment: Class 'ToolCall' is never used. ########## api/src/main/java/org/apache/flink/agents/api/util/CollectionUtils.java: ########## @@ -0,0 +1,68 @@ +/* + * 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.util; + +import java.util.Collection; +import java.util.Map; + +/** Utility methods for Collection operations in the Flink Agents framework. */ +public final class CollectionUtils { Review Comment: Class 'CollectionUtils' is never used ########## plan/src/main/java/org/apache/flink/agents/plan/resourceprovider/JavaSerializableResourceProvider.java: ########## @@ -39,14 +41,18 @@ public JavaSerializableResourceProvider( @Override public Resource provide(Callable<Resource> getResource) throws Exception { Review Comment: For SerializableResourceProvider, we should get the SerializableResource by deserialization rather than construct it. You can refer to the PythonSerializableResourceProvider in python implementation. ########## plan/src/main/java/org/apache/flink/agents/plan/resourceprovider/ToolResourceProvider.java: ########## @@ -0,0 +1,96 @@ +/* + * + * 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.plan.resourceprovider; + +import org.apache.flink.agents.api.resource.Resource; +import org.apache.flink.agents.api.resource.ResourceType; +import org.apache.flink.agents.api.tools.ToolMetadata; +import org.apache.flink.agents.plan.JavaFunction; +import org.apache.flink.agents.plan.tools.FunctionTool; +import org.apache.flink.agents.plan.tools.ToolMetadataFactory; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.concurrent.Callable; + +/** + * Resource provider for tools created from static Java methods annotated with @Tool. Stores the + * reflective identity to reconstruct a FunctionTool at runtime. + */ +public class ToolResourceProvider extends ResourceProvider { Review Comment: Can we use JavaSerializableResourceProvider rather than introduce a new type of ResourceProvider, which add the complexity of the serialization/deserialization of AgentPlan and also break the AgentPlan compatibility between python and java. You may modify the currently implementation of JavaSerializableResourceProvider and you can refer to the PythonSerializableResourceProvider in python. The key assumption is the resource in SerializableResourceProvider should be json serializable. In our design, Tool should be regarded as SerializableResource, and be json serializable. -- 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-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org