Skip to main content

GoodAI-LTM

GoodAI-LTM equips agents with text-based long-term memory by combining essential components such as

text embedding models, reranking, vector databases, memory and query rewriting, automatic chunking,

chunk metadata, and chunk expansion. This package is specifically designed to offer a dialog-centric

memory stream for social agents.

Additionally, GoodAI-LTM includes a conversational agent component (LTMAgent) for seamless

integration into Python-based apps.

Installation

pip install goodai-ltm

Usage of LTMAgent

Call the reply method of an LTMAgent instance to get a response from the agent.

from goodai.ltm.agent import LTMAgent



agent = LTMAgent(model="gpt-3.5-turbo")

response = agent.reply("What can you tell me about yourself?")

print(response)

The model parameter can be the name of any model supported by the litellm library.

A session history is maintained automatically by the agent. If you want to start a

new session, call the new_session method.

agent.new_session()

print(f"Number of messages in session: {len(agent.session.message_history)}")    

The agent has a conversational memory and also a knowledge base. You can tell the agent

to store knowledge by invoking the add_knowledge method.

agent.clear_knowledge()

agent.add_knowledge("The user's birthday is February 10.")

agent.add_knowledge("Refer to the user as 'boss'.")

response = agent.reply("Today is February 10. I think this is an important date. Can you remind me?")

print(response)

LTMAgent is a seamless RAG system. The ltm_agent_with_wiki example

shows how to add Wikipedia articles to the agent's knowledge base.

You can persist the agent's configuration and its memories/knowledge by obtaining

its state as a string via the state_as_text method.

state_text = agent.state_as_text()

# Persist state_text to secondary storage

To build an agent from state text, call the from_state_text method.

agent2 = LTMAgent.from_state_text(state_text)

Note that this does not restore the conversation session. The persist the conversation session

call the state_as_text method of the session.

from goodai.ltm.agent import LTMAgentSession



session_state_text = agent.session.state_as_text()

# session_state_text can be persisted in secondary storage

# The session.session_id field can serve as an identifier of the persisted session

# Now let's restore the session in agent2

p_session = LTMAgentSession.from_state_text(session_state_text)

agent2.use_session(p_session)

Additional information

Visit the Github page: https://github.com/GoodAI/goodai-ltm

Metadata

Release files for goodai-ltm 0.4.4

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

Source distribution (sdist)

Source distribution for goodai-ltm 0.4.4
File Size Uploaded
goodai-ltm-0.4.4.tar.gz 143.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for goodai-ltm 0.4.4
File Interpreter ABI Platform
goodai_ltm-0.4.4-py3-none-any.whl Python 3 none any Details

Total release size: 313.4 kB

Release files / goodai-ltm-0.4.4.tar.gz

Download URL goodai-ltm-0.4.4.tar.gz
Size 143.5 kB
Tags Source
SHA-256 checksum
How to use checksums
94dba3f6361861387da48fc46ae72a4e00ab5aaae15cbc207d4c728a9857c25a
BLAKE2b-256 checksum
How to use checksums
8565a4cea4d6ad9626a811b3c575014bca437714cfc7d5d7ed6464b2b29dfa50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / goodai_ltm-0.4.4-py3-none-any.whl

Download URL goodai_ltm-0.4.4-py3-none-any.whl
Size 170.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef8d11614e99be6653eba6955d5abe274e82c5d9300ed3710e08e7b05181e60a
BLAKE2b-256 checksum
How to use checksums
d0a79fd78232c2e1eb0db25f0a754b1ae7f5158eaf407e7317c49419b817b387
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.4.4 This release

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

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