-
Notifications
You must be signed in to change notification settings - Fork 29
feat: add a new internal analyze_files tool with supporting infrastructure for file attachment handling #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
58d7fc8 to
f31733d
Compare
f91813c to
958edcc
Compare
src/uipath_langchain/agent/tools/internal_tools/analyze_files_tool.py
Outdated
Show resolved
Hide resolved
| class AnalyzeFileTool(StructuredToolWithOutputType, ToolWrapperMixin): | ||
| pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is ok for now, but we will have to revise this at some point.
- It doesn't provide a nice way to compose functionalities (like file handling & static args)
- It risks other code relying on
isinstance(AnalyzeFileTool). In my design, systems would only search of Mixins
| """Agent Graph state for standard loop execution.""" | ||
|
|
||
| messages: Annotated[list[AnyMessage], add_messages] = [] | ||
| job_attachments: Annotated[dict[str, Attachment], add_job_attachments] = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this is ok for now but we will likely change our internal state management in the near future
| results = [] | ||
| for json_path in json_paths: | ||
| expr = parse(json_path) | ||
| matches = expr.find(data) | ||
| results.extend([match.value for match in matches]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if some of the paths overlap?
ie: $.attachments[*] vs $attachments[0]
In that case we will have duplicate matches in the result. Is that a problem?
If we assume we will get disjoint paths (which is the case for the paths you extract earlier), we could at least make it clear in the docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the paths overlap the function will return duplicates. Currently this is not a problem because the get_json_paths_by_type function is producing disjoint paths by design. I will update the docstring to make this behavior clear.
| def create_model( | ||
| schema: dict[str, Any], | ||
| ) -> Type[BaseModel]: | ||
| model, namespace = transform_with_modules(schema) | ||
| corrected_namespace: dict[str, Any] = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm really not a fan of this... but there is no way around this.
- Our InputModel is dynamically generated from json schema -> unavoidable
- We need to dynamically extend the AgentGraphState with the InputModel, otherwise we do not have the inputs in the state -> almost unavoidable
- AgentGraphState is then inspected by langgraph internals with get_type_hints(), which will fail to resolve dynamic types unless we do this. We have no mechanism to pass a local namespace through.
7c81f33 to
abcc021
Compare
6a9b2fb to
5fe66f5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please squash commits before merging
Key Changes
Technical Highlights
JSON Schema Converter
The converter solves a critical challenge with dynamically generated Pydantic models by:
Why this was needed: Dynamically generated Pydantic models need proper module references for type introspection to work correctly. Without this, frameworks that rely on typing.get_type_hints() (like LangGraph) fail to resolve forward references in nested models, breaking validation and serialization.