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.4.tar.gz (143.5 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.4-py3-none-any.whl (170.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: goodai-ltm-0.4.4.tar.gz
  • Upload date:
  • Size: 143.5 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.4.tar.gz
Algorithm Hash digest
SHA256 94dba3f6361861387da48fc46ae72a4e00ab5aaae15cbc207d4c728a9857c25a
MD5 37c6ce480f1f7acb22cc525ed9b55ef3
BLAKE2b-256 8565a4cea4d6ad9626a811b3c575014bca437714cfc7d5d7ed6464b2b29dfa50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: goodai_ltm-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 170.0 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ef8d11614e99be6653eba6955d5abe274e82c5d9300ed3710e08e7b05181e60a
MD5 ff15bdce0661263c8114174046020b8f
BLAKE2b-256 d0a79fd78232c2e1eb0db25f0a754b1ae7f5158eaf407e7317c49419b817b387

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