Display Dataframe
Tool for rendering the most recently displayed papers as a DataFrame artifact for the front-end.
Call this tool when you need to present the current set of retrieved papers to the user (e.g., "show me the papers", "display results"). It reads the 'last_displayed_papers' dictionary from the agent state and returns it as an artifact that the UI will render as a pandas DataFrame. This tool does not perform any new searches or filtering; it only displays the existing list. If no papers are available, it raises NoPapersFoundError to signal that a search or recommendation must be executed first.
DisplayDataFrameInput
Bases: BaseModel
Pydantic schema for displaying the last set of papers as a DataFrame artifact.
Fields
state: Agent state dict containing the 'last_displayed_papers' key. tool_call_id: LangGraph-injected identifier for this tool invocation.
Source code in aiagents4pharma/talk2scholars/tools/s2/display_dataframe.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
NoPapersFoundError
Bases: Exception
Exception raised when no research papers are found in the agent's state.
This exception helps the language model determine whether a new search or recommendation should be initiated.
Example
if not papers: raise NoPapersFoundError("No papers found. A search is needed.")
Source code in aiagents4pharma/talk2scholars/tools/s2/display_dataframe.py
32 33 34 35 36 37 38 39 40 41 42 |
|
display_dataframe(tool_call_id, state)
Render the last set of retrieved papers as a DataFrame in the front-end.
This function reads the 'last_displayed_papers' key from state, fetches the corresponding metadata dictionary, and returns a Command with a ToolMessage containing the artifact (dictionary) for the front-end to render as a DataFrame. If no papers are found in state, it raises a NoPapersFoundError to indicate that a search or recommendation must be performed first.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_call_id
|
str
|
LangGraph-injected unique ID for this tool call. |
required |
state
|
dict
|
The agent's state containing the 'last_displayed_papers' reference. |
required |
Returns:
Name | Type | Description |
---|---|---|
Command |
Command
|
A command whose update contains a ToolMessage with the artifact (papers dict) for DataFrame rendering in the UI. |
Raises:
Type | Description |
---|---|
NoPapersFoundError
|
If no entries exist under 'last_displayed_papers' in state. |
Source code in aiagents4pharma/talk2scholars/tools/s2/display_dataframe.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|