prompts
zocrates.agents.common.prompts ¶
Common prompt templates, formatters, and citation guidelines for Zocrates agents.
_clean_author_name ¶
Extract surname or primary identifier from a formatted author name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Raw author name string, potentially formatted as "Last, First". |
required |
Returns:
| Type | Description |
|---|---|
str
|
Cleaned surname or trimmed author name string. |
_format_authors_clean ¶
_format_year_clean ¶
Format year cleanly, omitting empty or 'N/A' values.
Source code in zocrates/agents/common/prompts.py
format_active_items ¶
Format active context items from session state for insertion into agent prompts.
Supports a hierarchical format when a parent item has multiple converted attachments and/or child notes. When a parent has exactly one converted attachment and no notes the output is byte-identical to the legacy flat format so existing prompts and tests are unaffected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
active_items
|
list[dict[str, Any]] | None
|
List of item dictionaries representing active selections in
Zotero UI. Each entry may optionally include a |
required |
include_keys
|
bool
|
Whether to include |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted multi-line Markdown string. |
Source code in zocrates/agents/common/prompts.py
format_retrieved_evidence_str ¶
Format accumulated evidence chunks into a clean XML-tagged block.
Suitable for passing into agent prompts or sufficiency evaluators.
Encloses chunks inside
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evidence_chunks
|
list[dict[str, Any]] | None
|
List of serialized evidence chunk dictionaries. |
required |
Returns:
| Type | Description |
|---|---|
str
|
XML string summarizing all retrieved evidence chunks. |
Source code in zocrates/agents/common/prompts.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
resolve_active_item_entry ¶
Resolve a Zotero item key into an enriched active-context entry dict.
Queries the syncer DB for the parent item's converted attachments and child
notes, producing a children list compatible with format_active_items.
Attachment entries are only included when their OKF bundle (document.md)
exists on disk. Child notes are summarized non-LLM: notes shorter than 50
words are inlined into inline_text (capped at 300 chars), longer notes
carry inline_text=None and are referenced by key/word count only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
syncer
|
Any
|
The active |
required |
key
|
str
|
Zotero item key of the parent item. |
required |
title
|
str | None
|
Optional human-readable title override; falls back to the DB
item title, then |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Enriched item dict with |
dict[str, Any]
|
and optional |
dict[str, Any]
|
|
Source code in zocrates/agents/common/prompts.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
strip_snippet_keys ¶
Programmatically strip item key attributes from snippet XML tags.
Leaves all other XML attributes (e.g. paper, page, authors) and snippet text content intact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snippet_xml
|
str
|
XML-formatted snippet string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Snippet XML string with all ' key="..."' attributes removed. |