wenjin272 commented on code in PR #81:
URL: https://github.com/apache/flink-agents/pull/81#discussion_r2250654269
##########
python/flink_agents/plan/resource_provider.py:
##########
@@ -81,11 +81,27 @@ class PythonResourceProvider(ResourceProvider):
clazz: str
kwargs: Dict[str, Any]
- def provide(self) -> Resource:
+ def provide(self, **kwargs: Any) -> Resource:
"""Create resource in runtime."""
module = importlib.import_module(self.module)
cls = getattr(module, self.clazz)
- return cls(**self.kwargs)
+ resource = cls(**self.kwargs)
+ if self.type == ResourceType.CHAT_MODEL:
+ plan = kwargs["plan"]
+ # bind tools
+ if resource.tools is not None:
+ resource.bind_tools(
+ [
+ plan.get_resource(name, ResourceType.TOOL)
+ for name in resource.tools
+ ]
+ )
+ # bind prompt
+ if resource.prompt is not None and isinstance(resource.prompt,
str):
+ resource.prompt = plan.get_resource(
+ resource.prompt, ResourceType.PROMPT
+ )
Review Comment:
Yes, in the previous Implementation, the model and the framework should both
be aware of the tools that model need bind, which is not elegant and clean.
Currently, it is the responsibility of model implementation to decide which
tool to bind and how to bind, and resource provider only provide fetcher to
resource to get other resource declared in the same Agent.
--
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]