xintongsong commented on code in PR #211:
URL: https://github.com/apache/flink-agents/pull/211#discussion_r2375154645


##########
python/flink_agents/api/execution_environment.py:
##########
@@ -256,6 +256,42 @@ def add_tool(self, name: str, func: Callable) -> 
"AgentsExecutionEnvironment":
         self._resources[ResourceType.TOOL][name] = func
         return self
 
+    def add_mcp_server(
+        self, name: str, mcp_server: MCPServer
+    ) -> "AgentsExecutionEnvironment":
+        """Add an MCP server to the agent execution environment.
+
+        Parameters
+        ----------
+        name : str
+            The name of the MCP server, should be unique in the same Agent.
+        mcp_server : MCPServer
+            The MCP server resource instance.
+
+        Returns:
+        -------
+        AgentsExecutionEnvironment
+            The environment contains registered embedding model setup.
+        """
+        if name in self._resources[ResourceType.MCP_SERVER]:
+            msg = f"MCP server {name} already defined"
+            raise ValueError(msg)
+        self._resources[ResourceType.MCP_SERVER][name] = mcp_server
+        return self
+
+    def __add_resource(

Review Comment:
   1. I'd suggest to let users create the resource descriptors and pass them 
them in.
   2. In this way, we can also combine all the `add_xxx()` into one 
`add_resource()`, where we can check whether the argument is a descriptor or 
serializable resource and apply different approaches.



##########
python/flink_agents/examples/quickstart/product_shipping_question_record.py:
##########
@@ -0,0 +1,97 @@
+################################################################################
+#  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.
+#################################################################################
+from pathlib import Path
+
+from pyflink.common import Duration, WatermarkStrategy
+from pyflink.datastream import StreamExecutionEnvironment
+from pyflink.datastream.connectors.file_system import FileSource, StreamFormat
+
+from flink_agents.api.execution_environment import AgentsExecutionEnvironment
+from flink_agents.examples.quickstart.agents.review_analysis_agent import (
+    ProductReview,
+)
+from 
flink_agents.examples.quickstart.agents.shipping_question_record_react_agent 
import (
+    record_shipping_questions,
+    review_analysis_and_record_agent,
+)
+from flink_agents.integrations.chat_models.ollama_chat_model import (
+    OllamaChatModelConnection,
+)
+
+current_dir = Path(__file__).parent
+
+
+def main() -> None:

Review Comment:
   I think we should use file names like `react_agent_example`, 
`workflow_single_agent_example`, `workflow_multiple_agent_example`.



##########
python/flink_agents/examples/quickstart/agents/shipping_question_record_react_agent.py:
##########
@@ -0,0 +1,91 @@
+################################################################################
+#  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.
+#################################################################################
+from flink_agents.api.agents.react_agent import ReActAgent
+from flink_agents.api.chat_message import ChatMessage, MessageRole
+from flink_agents.api.prompts.prompt import Prompt
+from flink_agents.examples.quickstart.agents.review_analysis_agent import (
+    ProductReviewAnalysisRes,
+)
+from flink_agents.integrations.chat_models.ollama_chat_model import 
OllamaChatModelSetup
+
+
+def record_shipping_questions(id: str, review: str) -> None:

Review Comment:
   I'd suggest to move this to the example file. The advantage of ReAct is that 
you don't need to define the whole agent class. This is less obvious when agent 
components are defined in a separate file.



##########
python/flink_agents/examples/quickstart/agents/shipping_question_record_react_agent.py:
##########
@@ -0,0 +1,91 @@
+################################################################################
+#  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.
+#################################################################################
+from flink_agents.api.agents.react_agent import ReActAgent
+from flink_agents.api.chat_message import ChatMessage, MessageRole
+from flink_agents.api.prompts.prompt import Prompt
+from flink_agents.examples.quickstart.agents.review_analysis_agent import (
+    ProductReviewAnalysisRes,
+)
+from flink_agents.integrations.chat_models.ollama_chat_model import 
OllamaChatModelSetup
+
+
+def record_shipping_questions(id: str, review: str) -> None:

Review Comment:
   Maybe we should move all the model connections, prompts and tools into a 
common file. In this way, the differences between react and workflow would 
become more obvious.



##########
python/flink_agents/examples/quickstart/resources/record_shipping_question/product_review.txt:
##########
@@ -0,0 +1,17 @@
+{"id": "B010RRWKT4", "review": "Love these! I have 3 pairs...they're so 
comfortable - I'm on my feet all day & my feet actually don't hurt at the end 
of the day when I wear these :)\nI've learned to get these 1/2 size 
smaller....I'm normally a size 7 and the 6 1/2 fit perfectly"}

Review Comment:
   Why do we need 2 different dataset?



##########
python/flink_agents/examples/quickstart/product_shipping_question_record.py:
##########
@@ -0,0 +1,97 @@
+################################################################################
+#  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.
+#################################################################################
+from pathlib import Path
+
+from pyflink.common import Duration, WatermarkStrategy
+from pyflink.datastream import StreamExecutionEnvironment
+from pyflink.datastream.connectors.file_system import FileSource, StreamFormat
+
+from flink_agents.api.execution_environment import AgentsExecutionEnvironment
+from flink_agents.examples.quickstart.agents.review_analysis_agent import (
+    ProductReview,
+)
+from 
flink_agents.examples.quickstart.agents.shipping_question_record_react_agent 
import (
+    record_shipping_questions,
+    review_analysis_and_record_agent,
+)
+from flink_agents.integrations.chat_models.ollama_chat_model import (
+    OllamaChatModelConnection,
+)
+
+current_dir = Path(__file__).parent
+
+
+def main() -> None:
+    """Main function for the product shipping question record quickstart 
example.
+
+    This example demonstrates how to use the Flink Agents to analyze product 
reviews
+    and record shipping questions in a streaming pipeline. The pipeline reads 
product
+    reviews from a file, deserializes each review, and uses an LLM agent to 
extract
+    review scores and unsatisfied reasons. If the unsatisfied reasons are 
related to
+    shipping, the agent will call tool to record it. The results are printed 
to stdout.

Review Comment:
   I think we can say `message the shipping manager`. We don't need to actually 
send the message. We can say the tool is mocked and will simply print the 
messages. 



##########
python/flink_agents/api/execution_environment.py:
##########
@@ -256,6 +256,42 @@ def add_tool(self, name: str, func: Callable) -> 
"AgentsExecutionEnvironment":
         self._resources[ResourceType.TOOL][name] = func
         return self
 
+    def add_mcp_server(
+        self, name: str, mcp_server: MCPServer
+    ) -> "AgentsExecutionEnvironment":
+        """Add an MCP server to the agent execution environment.
+
+        Parameters
+        ----------
+        name : str
+            The name of the MCP server, should be unique in the same Agent.
+        mcp_server : MCPServer
+            The MCP server resource instance.
+
+        Returns:
+        -------
+        AgentsExecutionEnvironment
+            The environment contains registered embedding model setup.
+        """
+        if name in self._resources[ResourceType.MCP_SERVER]:
+            msg = f"MCP server {name} already defined"
+            raise ValueError(msg)
+        self._resources[ResourceType.MCP_SERVER][name] = mcp_server
+        return self
+
+    def __add_resource(

Review Comment:
   Same for `Agent`.



##########
python/flink_agents/examples/quickstart/agents/shipping_question_record_react_agent.py:
##########
@@ -0,0 +1,91 @@
+################################################################################
+#  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.
+#################################################################################
+from flink_agents.api.agents.react_agent import ReActAgent
+from flink_agents.api.chat_message import ChatMessage, MessageRole
+from flink_agents.api.prompts.prompt import Prompt
+from flink_agents.examples.quickstart.agents.review_analysis_agent import (
+    ProductReviewAnalysisRes,
+)
+from flink_agents.integrations.chat_models.ollama_chat_model import 
OllamaChatModelSetup
+
+
+def record_shipping_questions(id: str, review: str) -> None:

Review Comment:
   And we really should have tool calls in the workflow agents.



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