Skip to content

Update API format and support multiple string/pre-extracted inputs - #11

Merged
danmichaeljones merged 4 commits into
mainfrom
batch_input_types
Mar 19, 2026
Merged

Update API format and support multiple string/pre-extracted inputs#11
danmichaeljones merged 4 commits into
mainfrom
batch_input_types

Conversation

@danmichaeljones

@danmichaeljones danmichaeljones commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Update serialisation to use new API input format and support multiple string/pre-extracted inputs.

  • The "simple" adds (using python types for string / conversation) work same as before
  • Adding StringContent has been extended to also support content: list[str]
client.memories.add(
    StringContent(content=["User prefers dark mode.", "User likes pizza."]),
    user_id="...",
)
  • The pre-extracted data type has been (non-backwards-compatibly) updated so that PreExtractedContent contains list[PreExtractedItem].
client.memories.add(
    PreExtractedContent(items=[
        PreExtractedItem(content="User prefers dark mode.", topic="UserKnowledge"),
        PreExtractedItem(content="User likes pizza.", topic="UserKnowledge"),
    ]),
    user_id="...",
)

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@danmichaeljones
danmichaeljones marked this pull request as ready for review March 18, 2026 14:45
@danmichaeljones
danmichaeljones requested a review from a team March 18, 2026 14:45
Comment thread src/engram/_serialization/_builders.py Outdated
if isinstance(content, StringContent):
return {"type": "string", "content": content.content}
if isinstance(content.content, list):
return {"string": {"content": content.content}}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels like content inside content.
Maybe all our dataclasses should be renamed to input, and content would refer only to the atomic part (the actual texts)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good shout - I've renamed content to input throughout so that content now only refers to the inner fields. I also updated the .add() arg/type alias to input_data: AddInput to match (but not shadow input builtin)

@danmichaeljones
danmichaeljones merged commit bdd3d31 into main Mar 19, 2026
14 checks passed
@danmichaeljones
danmichaeljones deleted the batch_input_types branch March 19, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants