-
Notifications
You must be signed in to change notification settings - Fork 33
feat: Addition of DF tool #721
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
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a29ef1e
Integration-e2e
UIPath-Harshit 7ca3564
Added the prompts to be injected here.
UIPath-Harshit a6d4b2e
Added the data_fabric tool
UIPath-Harshit 3510f6b
Updated
UIPath-Harshit 7338c4d
Merge branch 'feat-df-agent-integrations' of https://github.com/UiPat…
UIPath-Harshit 607816e
Merge remote-tracking branch 'origin/main' into feat-df-agent-integra…
UIPath-Harshit 5f25d1e
Merge remote-tracking branch 'origin/main' into feat-df-agent-integra…
UIPath-Harshit 767c707
Added updated agent definition
UIPath-Harshit 98460a9
use name & field names instead of display name
milind-jain-uipath 9396ae2
Merge branch 'main' of https://github.com/UiPath/uipath-langchain-pyt…
milind-jain-uipath 55a49b2
removed count(*) examples
milind-jain-uipath 77823d2
Merge branch 'main' into feat-df-agent-integrations-fixes
milind-jain-uipath fff4b2e
removed count(*) examples + prompt change
milind-jain-uipath 9dc5d28
Merge branch 'feat-df-agent-integrations-fixes' of https://github.com…
milind-jain-uipath 858de17
Merge branch 'main' into feat-df-agent-integrations-fixes
milind-jain-uipath File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| """State initialization node for the ReAct Agent graph.""" | ||
|
|
||
| import logging | ||
| from typing import Any, Callable, Sequence | ||
|
|
||
| from langchain_core.messages import HumanMessage, SystemMessage | ||
|
|
@@ -10,20 +11,51 @@ | |
| get_job_attachments, | ||
| parse_attachments_from_conversation_messages, | ||
| ) | ||
| from .types import AgentResources | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def create_init_node( | ||
| messages: Sequence[SystemMessage | HumanMessage] | ||
| | Callable[[Any], Sequence[SystemMessage | HumanMessage]], | ||
| | Callable[..., Sequence[SystemMessage | HumanMessage]], | ||
| input_schema: type[BaseModel] | None, | ||
| is_conversational: bool = False, | ||
| resources_for_init: AgentResources | None = None, | ||
| ): | ||
| def graph_state_init(state: Any) -> Any: | ||
| async def graph_state_init(state: Any) -> Any: | ||
| # --- Data Fabric schema fetch (INIT-time) --- | ||
| schema_context: str | None = None | ||
| if resources_for_init: | ||
| from uipath_langchain.agent.tools.datafabric_tool import ( | ||
| fetch_entity_schemas, | ||
| format_schemas_for_context, | ||
| get_datafabric_entity_identifiers_from_resources, | ||
| ) | ||
|
|
||
| entity_identifiers = get_datafabric_entity_identifiers_from_resources( | ||
| resources_for_init | ||
| ) | ||
| if entity_identifiers: | ||
| logger.info( | ||
| "Fetching Data Fabric schemas for %d identifier(s)", | ||
| len(entity_identifiers), | ||
| ) | ||
| entities = await fetch_entity_schemas(entity_identifiers) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be single api outside tool |
||
| schema_context = format_schemas_for_context(entities) | ||
|
|
||
| # --- Resolve messages --- | ||
| resolved_messages: Sequence[SystemMessage | HumanMessage] | Overwrite | ||
| if callable(messages): | ||
| resolved_messages = list(messages(state)) | ||
| if schema_context: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be keyed to additional_context_available. That derives from schema_context. |
||
| resolved_messages = list( | ||
| messages(state, additional_context=schema_context) | ||
| ) | ||
| else: | ||
| resolved_messages = list(messages(state)) | ||
| else: | ||
| resolved_messages = list(messages) | ||
|
|
||
| if is_conversational: | ||
| # For conversational agents we need to reorder the messages so that the system message is first, followed by | ||
| # the initial user message. When resuming the conversation, the state will have the entire message history, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/uipath_langchain/agent/tools/datafabric_tool/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| """Data Fabric tool module for entity-based SQL queries.""" | ||
|
|
||
| from .datafabric_tool import ( | ||
| create_datafabric_tools, | ||
| fetch_entity_schemas, | ||
| format_schemas_for_context, | ||
| get_datafabric_contexts, | ||
| get_datafabric_entity_identifiers_from_resources, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "create_datafabric_tools", | ||
| "fetch_entity_schemas", | ||
| "format_schemas_for_context", | ||
| "get_datafabric_contexts", | ||
| "get_datafabric_entity_identifiers_from_resources", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
lets move this to a helper method behind datafabric_tool folder. Few principles:
Similar pattern as tools_factory.py.