Skip to main content

A text memory meant to be used with conversational language models.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goodai-ltm-0.4.3.tar.gz (143.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

goodai_ltm-0.4.3-py3-none-any.whl (169.9 kB view details)

Uploaded Python 3

File details

Details for the file goodai-ltm-0.4.3.tar.gz.

File metadata

  • Download URL: goodai-ltm-0.4.3.tar.gz
  • Upload date:
  • Size: 143.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for goodai-ltm-0.4.3.tar.gz
Algorithm Hash digest
SHA256 c356b81fba271fc7b338c2a91ac98f3c9b2256068e9c359303972e10c18ffe96
MD5 9c137f7e9a359829a135d1c63fcbc02c
BLAKE2b-256 f03534853235cea763fc711cac4a0d344f69116d46e49638f6ca56fc865f03e7

See more details on using hashes here.

File details

Details for the file goodai_ltm-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: goodai_ltm-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 169.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for goodai_ltm-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bfebc32027c2b6627dfd08c7fbb4c53a882201796a59c58f6050534b1889060d
MD5 55ad884d5e5b3f7b7b7d08e1a464f035
BLAKE2b-256 fa3fbb236ba4dda781d8ecca8396c0c41f4d6c06870e69ac35432bd7342ffc7e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page