Skip to main content

SwastikAI

This is the official Python SDK of SwastikAI. It allows you to easily create and/or retrieve memories for your AI agents. Whether you've one agent, a multi-agent system or an agent based on LLM or SLM - SwastikAI works seamlessly across platforms and irrespective of your choice of AI model as long as the memory requirement is in natural language. Visit https://www.swastikai.com. to get your API_KEY and grab some generous free usage credits.

Table of Contents


SwastikAI Workflow

Installation

Easily install using pip:

pip install swastikai

Quick Start

Quick example code showing how to initialize the memory client and start using it in just few lines of code.


Memory Creation

Making a Request

from swastikai.memory import personal_memory
memory_client = personal_memory(api_key="SWK_API_KEY") #Get your API KEY from www.swastikai.com
paylod = {
    "agent_details": {
    "agent_id": "Sample_Agent",
    "user_id": "John",
    "agent_description": "This is a very helpful personal assisstant.",
    },
    "memories": "",
    "last_user_prompt": "I love mangoes",
    "last_ai_response": "",
    "chat_history": [],
    "memory_category": "personal_memory"
    }

response = memory_client.create_memory(paylod)
print(response)

Memory Creation Payload

agent_details = {
  "agent_details": {
    "company_id": "string",
    "department_id": "string",
    "team_id": "string",
    "agent_id": "string",
    "user_id": "string",
    "agent_type": "iA",
    "agent_description": "string"
  },
  "memories": "string",
  "last_user_prompt": "string",
  "memory_category": "personal_memory"
}

Agent Details

  • company_id (string) (Optional): The company ID/Name. This can be used to differentiate how a memory is stored.This field sits at the top-most hierarchy.
    Example:
    SwastikAI
    
  • department_id (string) (Optional): The Department ID/Name. This can be used to differentiate how a memory is stored. This field (if provided) sits just below Company ID in hierarchy.
    Example:
    Reasearch and Development
    
  • team_id (string) (Optional): The Team ID/Name. This can be used to differentiate how a memory is stored. This field (if provided) sits just below Department ID in hierarchy.
    Example:
    Development Team
    
  • agent_id (string): The Agent ID/Name. This is a mandatory field. This is used to differentiate how a memory is stored. This field sits just below Team ID in hierarchy.
    Example:
    Conversation Personal Agent
    
  • user_id (string): The User ID/Name. This is a mandatory field. This is used to differentiate how a memory is stored. This field sits just below Agent ID in hierarchy.
    Example:
    John Smith
    
  • agent_type (string) (Optional): The type of the agent. This is an OPTIONAL field. The Default value and the only value allowed is
    iA
    
  • agent_description (string): This is the description of your AI agent, a very important and mandatory field. Be concise but properly describe what it is and what it does. This information is very crucial for the memory system as it deduces memory based upon what the agent does and thereby what it needs to remember.
    Example:
    This is a Personal Assistant agent. The main role of the agent is to assist the user with writing and editing e-mails and messages.
    

Other Parameters

  • memories (string) (Optional): A string of memories as received in earlier retrieve memory api calls. These are the existing memories that the system already has. This really helps in cutting down the cost and increases efficiency in case available and when the available memories are relevant to the context. This also helps in eradicating duplicate memory creation, if available with you but not provided, chances of duplicate memory creation increases multifold
    Example memories to send:
    "User loves apples"
    "User loves to dance"
    "User always prefers a polite conversation"
    
  • last_user_prompt (string): The latest prompt that the end user used. In a chat scenario this basically represents the user message that the system will provide to the LLM for a reply.
    Example:
    What should I wear today?
    
  • memory_category (string) (Optional): The type of memory category that needs to be used. Currently only Personal memories are supported.
    personal_memory
    

Memory Retrieval

All remains same just change the calling function to retrieve_memory

response = memory_client.retrieve_memory(paylod)
print(response)

Memory Retrieval Payload

Same as memory creation payload with one addition of chat_history parameter.

{
  "agent_details": {
    "company_id": "string",
    "department_id": "string",
    "team_id": "string",
    "agent_id": "string",
    "user_id": "string",
    "agent_type": "iA",
    "agent_description": "string"
  },
  "chat_history": [
    {}
  ],
  "last_user_prompt": "string",
  "memory_category": "personal_memory"
}
  • chat_history (list[dict]) (Optional): A list of dictionaries containg the chat history.
    1. The chat history should be in ascending order i.e. latest conversation at the last in the list.
    2. The only valid value for sender is User and AI Agent only and case sensitive.
      [
        {"sender": "User", "message": "Hello!"},
        {"sender": "AI Agent", "message": "Hi, how can I help you?"},
        {"sender": "User", "message": "I have a question about my order."},
        {"sender": "AI Agent", "message": "Sure, can you provide the order ID?"}
      ]
    

Check Account Balance

A simple GET request to know the current credit balance

response = memory_client.get_account_balance()
print(response["credit_balance"])

Async Requests

from swastikai.memory_async import personal_memory

API Documentation

Please find the API documentation in at https://api.swastikai.com/.

Metadata

Release files for swastikai 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swastikai 1.0.6
File Size Uploaded
swastikai-1.0.6.tar.gz 11.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swastikai 1.0.6
File Interpreter ABI Platform
swastikai-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 24.3 kB

Release files / swastikai-1.0.6.tar.gz

Download URL swastikai-1.0.6.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7614a4e0b8c9da7cae4b6b329fe16f2cdc9d1723308504b8e0d2ef389e1e7b60
BLAKE2b-256 checksum
How to use checksums
4ab05b68d28a71ed377cec654fd7af73d2c7c5ed3af391cc2af9831ea0383709
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.12

Release files / swastikai-1.0.6-py3-none-any.whl

Download URL swastikai-1.0.6-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33268f438e10368e375f3ea137371d2ea7ca8b237cb5bdd09c76601e9a0aeb21
BLAKE2b-256 checksum
How to use checksums
40d40d95e4c3ee5bcbf7da5a2869628a6c6351f1651ad303d6c1d5aea73e4e57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.12

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page