Skip to main content

Echo

Echo is a lightweight and intuitive Python library for building and managing LLM-based chat conversations
It provides structured tools for managing chat, including FIFO queue management,
conversation topic evaluation, pertinence filtering, archiving, and more

Features

  • Capacity: Limit the number of messages stored in the conversation (FIFO)
  • Topic evaluation: Evaluate the topic of the conversation and update it dynamically
  • Pertinence filtering: Filter out irrelevant messages based on the current topic
  • Archive messages: Archive the original message, keep a summarized version in the chat

Algorithms

Topic Evaluation

  • Init Message Topic (IMT) - The conversation topic is inferred solely from the content of the first message
  • Nth Message Topic (NMT) - The conversation topic is inferred from the content of the first N messages
  • Anchored Topic Evaluation (ATE) - The conversation topic is initially anchored using the first N messages
    Afterward, the topic is dynamically re-evaluated with each new message,
    allowing the model to adapt to topic shifts while maintaining stability around the original anchor
    A new message may or may not affect the topic,
    depending on whether it introduces a significant shift in content relative to the anchor

gemini.py

import google.generativeai as genai
from synapse import Synapse

class GeminiClient(Synapse):
    def __init__(self, model_name: str = "gemini-2.5-flash-lite"):
        genai.configure(api_key='<API Key>')
        self.model = genai.GenerativeModel(model_name)

    def prompt(self, text: str) -> str:
        """ Sends a single string to the model and returns the text response """
        try:
            response = self.model.generate_content(text)
            return response.text
        except Exception as e:
            return f"An error occurred: {e}"

main.py

# main.py

client = GeminiClient()

rec = Record(
    synapse=client,
    topic_evaluation_algorithm='SATE2'
)

rec.add(
    Message(
        text="Hello World",
        author='John Doe'
    )
)

Examples

Archive Example

[Message]
"""
The capital city of England is London.
London is a large, historic, and highly influential city located in the southeast of England, along the River Thames.
It has been a major settlement for nearly 2,000 years, originally founded by the Romans as Londinium.
Key characteristics:
- Political center: Home to the UK government, Parliament, and the Prime Minister’s residence at 10 Downing Street.
- Cultural hub: Famous landmarks include Big Ben, Buckingham Palace, Tower Bridge, and the British Museum.
- Economic powerhouse: One of the world’s leading financial centers, especially around the City of London and Canary Wharf.
- Diverse and global: Known for its multicultural population, languages, food, and arts.
- Transport and infrastructure: Extensive public transport, including the London Underground, one of the oldest metro systems in the world.
- London combines deep historical roots with modern global influence, making it one of the most important cities in the world.
"""

[Distilled Message]
"Description of London, England. (Archived 9e63c59908b84572bb6356af3db6a015)"

Pertinence Filter and Topic Evaluation Examples

1. Topic Evaluation Algorithm: Non-Strict Init Message Topic (NSIMT)

[Messages]
"The sky is blue."
"The sun is yellow."
"My name is John Doe."
"I am 21 years old."

[Evaluated Topic]
"Observations of the world"

[Included Messages]
"The sky is blue."
"The sun is yellow."

[Excluded Messages]
"My name is John Doe."
"I am 21 years old."

2. Topic Evaluation Algorithm: Strict Init Message Topic (SIMT)

[Messages]
"The sky is blue."
"The sun is yellow."
"My name is John Doe."
"I am 21 years old."

[Evaluated Topic]
"The Sky's Color"

[Included Messages]
"The sky is blue."
"The sun is yellow."

[Excluded Messages]
"My name is John Doe."
"I am 21 years old."

3. Topic Evaluation Algorithm: Non-Strict Nth Message Topic - First 2 Messages (NSNMT2)

[Messages]
"The sky is blue."
"The sun is yellow."
"My name is John Doe."
"I am 21 years old."

[Evaluated Topic]
"Observations about the environment"

[Included Messages]
"The sky is blue."
"The sun is yellow."

[Excluded Messages]
"My name is John Doe."
"I am 21 years old."

4. Topic Evaluation Algorithm: Strict Nth Message Topic - First 2 Messages (SNMT2)

[Messages]
"The sky is blue."
"The sun is yellow."
"My name is John Doe."
"I am 21 years old."

[Evaluated Topic]
"Sky and Sun Colors"

[Included Messages]
"The sky is blue."
"The sun is yellow."

[Excluded Messages]
"My name is John Doe."
"I am 21 years old."

5. Topic Evaluation Algorithm: Non-Strict Anchored Topic Evaluation - First 2 Messages (NSATE2)

[Messages]
"The sky is blue."
"The sun is yellow."
"My name is John Doe."
"I am 21 years old."

[Evaluated Topic]
"Observations about the natural world"

6. Topic Evaluation Algorithm: Strict Anchored Topic Evaluation - First 2 Messages (SATE2)

[Messages]
"The sky is blue."
"The sun is yellow."
"My name is John Doe."
"I am 21 years old."

[Evaluated Topic]
Sky and Sun Colors

Metadata

Release files for python-echo 0.1.0

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

Source distribution (sdist)

Source distribution for python-echo 0.1.0
File Size Uploaded
python_echo-0.1.0.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-echo 0.1.0
File Interpreter ABI Platform
python_echo-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / python_echo-0.1.0.tar.gz

Download URL python_echo-0.1.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
47decdcf8d1678ff1d47cd8b14938bbf995150fc53b563398146b561039c9305
BLAKE2b-256 checksum
How to use checksums
a68aa9ff101870fadda727a40c62ef3dfec271f3d7bba33d3db7e9d45f0ef09c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Release files / python_echo-0.1.0-py3-none-any.whl

Download URL python_echo-0.1.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
edf03f40cb70cb9151bfd2d370c5525c9fa0fe6bf67dc3ec438b8c261f873dbf
BLAKE2b-256 checksum
How to use checksums
0478de1ab98affb047f6d2b99cc27a23df36249e4022ae725e22688665ca0770
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.1.0 This release

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