Before adding memories, make sure to configure the API key in your environment.

You can add memories to a graph by using the add method. Add currently supports:

  • Raw Text: chunking will be handled automatically;
  • PDFs: parsing and chunking will be handled automatically;
  • …and more coming soon!

Adding text

  from circlemind import Circlemind

  # Initialize the client
  client = Circlemind()

  # Add a memory
  client.add(
    memory="Sophie enjoys hiking in the Italian Alps.",
    graph_id="customer-id-123"
  )

The graph_id parameter is optional. If not set, it defaults to the default graph.

Adding PDFs

  from pathlib import Path

  # Add a file
  client.add(
    memory=Path("path/to/file.pdf"),
    graph_id="customer-id-123"
  )

Metadata

You can also specify metadata to pass a dictionary of information that will be tied to the memory you’re creating. For example, this can be the document URL that can be used, at query time, to reference the sources used to produce an answer.

  from pathlib import Path

  # Add a file
  client.add(
    memory=Path("path/to/file.pdf"),
    graph_id="customer-id-123",
    metadata={"url": "https://path/to/file.pdf"}
  )