You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My code has become very slow, and it started when I received the following error:
Here is the text: c:\Users\memgpt\connectors\db.py:47: SAWarning: This declarative base already contains a class with the same class name and module name as memgpt.connectors.db.Memgpt_agent_testing_userModel, and will be replaced in the string-lookup table.
Model = type(class_name, (PassageModel,), {"tablename": table_name, "table_args": {"extend_existing": True}})
Please describe your setup
I have memgpt connected to postgres
I run memgpt dicetly from another pythonscript. (I have linked to the code later in the message)
MemGPT version = 0.2.7
I program on a computer with windows 11
I use the OpenAI Api
Here is my code:
import os
import openai
from pathlib import Path
from memgpt.agent import Agent as _Agent
from typing import Callable, Optional, List, Dict, Union, Any, Tuple
from memgpt.persistence_manager import LocalStateManager
import memgpt.constants as constants
import memgpt.system as system
import memgpt.utils as utils
import memgpt.presets.presets as presets
from memgpt.config import AgentConfig
from memgpt.interface import CLIInterface as interface
from memgpt.constants import MEMGPT_DIR
# Set the path to the .memgpt or config file
# MEMGPT_DIR = r"C:\Users\noahb\MemGPT\.memgpt"
def process_agent_step(agent, user_message, no_verify):
"""Copied from main.py (unpacks the content of agent.step())"""
new_messages, heartbeat_request, function_failed, token_warning = agent.step(user_message, first_message=False, skip_verify=no_verify)
skip_next_user_input = False
if token_warning:
user_message = system.get_token_limit_warning()
skip_next_user_input = True
elif function_failed:
user_message = system.get_heartbeat(constants.FUNC_FAILED_HEARTBEAT_MESSAGE)
skip_next_user_input = True
elif heartbeat_request:
user_message = system.get_heartbeat(constants.REQ_HEARTBEAT_MESSAGE)
skip_next_user_input = True
return new_messages, user_message, skip_next_user_input
def send_agent_a_message(agent, user_input, no_verify=False, allow_multi_step=True):
"""A convenience wrapper around the agent step, which:
1. Packages the first message correctly
2. Allows the agent to run back-to-back calls
"""
# package the message
user_message = system.package_user_message(user_input)
while True:
try:
new_messages, user_message, skip_next_user_input = process_agent_step(agent, user_message, no_verify)
if not allow_multi_step or not skip_next_user_input:
break
except KeyboardInterrupt:
print("User interrupt occured.")
input("Continue?")
except Exception as e:
print(f"An exception ocurred when running agent.step(): {e}")
# from dotenv import load_dotenv
# load_dotenv()
# Set your OpenAI API key
# os.environ["OPENAI_API_KEY"] = "OPENAI_API_KEY"
# cpacker: Assume I set the key with `export OPENAI_API_KEY=...`
# Point to your config file (or remove this line if you just want to use the default)
# hallo = os.environ["MEMGPT_CONFIG_PATH"] = Path.home().joinpath(".memgpt").joinpath("config").as_posix()
hallo = MEMGPT_DIR
# Necessary to avoid errors when LLM is invoked
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.api_base = "https://api.openai.com/v1"
# persona_desc = utils.get_persona_text(constants.DEFAULT_PERSONA)
persona_desc = utils.get_persona_text("1440.txt")
user_desc = utils.get_human_text("starter.txt")
# Create an AgentConfig option from the inputs
agent_config = AgentConfig(
# name="agent_4",
name="testing_user",
persona=persona_desc,
human=user_desc,
preset="memgpt_chat",
model="gpt-4",
model_endpoint_type="openai",
model_endpoint="https://api.openai.com/v1",
context_window=8192,
)
skip_verify = agent_config.model != "gpt-4"
USER_INPUT = ""
# NEW_AGENT = False
NEW_AGENT = False
if NEW_AGENT:
persistence_manager = LocalStateManager(agent_config)
memgpt_agent = presets.use_preset(
preset_name=agent_config.preset,
agent_config=agent_config,
model=agent_config.model,
persona=agent_config.persona,
human=agent_config.human,
interface=interface,
persistence_manager=persistence_manager,
)
# print("agent messages:", memgpt_agent.messages)
print("agent memories:", str(memgpt_agent.memory))
print("DEBUG first step")
# memgpt_agent.step(user_message="Hi my name is Bill Gates. I love the Windows OS!", first_message=True, skip_verify=skip_verify)
send_agent_a_message(agent=memgpt_agent, user_input="Hi my name is Bill Gates. I love the Windows OS!")
print("DEBUG second step")
input("continue?")
# memgpt_agent.step(user_message="I am 68 years old, born October 28, 1955", first_message=False, skip_verify=skip_verify)
send_agent_a_message(agent=memgpt_agent, user_input="I am 68 years old, born October 28, 1955")
print("DEBUG saving")
# print("agent messages:", memgpt_agent.messages)
print("agent memories:", str(memgpt_agent.memory))
memgpt_agent.save()
else:
memgpt_agent = _Agent.load_agent(interface, agent_config)
# memgpt_agent.step(user_message="What have i told you that i like to drink?", first_message=True, skip_verify=skip_verify)
# Let's test if the agent remembers my name
# memgpt_agent.step(user_message="Who am I?", first_message=False, skip_verify=skip_verify)
send_agent_a_message(agent=memgpt_agent, user_input="What country am i from?")
memgpt_agent.save()
The text was updated successfully, but these errors were encountered:
I also started seeing the same warning after updating MemGPT to the latest version.
MemGPT version 0.2.10
Archival Storage: PostgreSQL
❯ memgpt run
? Would you like to select an existing agent? Yes
? Select agent: agent_2
🔁 Using existing agent agent_2
.../MemGPT/memgpt/connectors/db.py:47: SAWarning: This declarative base already contains a class
with the same class name and module name as memgpt.connectors.db.Memgpt_agent_agent_2Model, and
will be replaced in the string-lookup table.
Model = type(class_name, (PassageModel,), {"__tablename__": table_name, "__table_args__":
{"extend_existing": True}})
Hit enter to begin (will request first MemGPT message)
My code has become very slow, and it started when I received the following error:
![image](https://private-user-images.githubusercontent.com/93727521/293291994-258988f3-87ab-473a-8470-093fe2264447.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMDg4MzksIm5iZiI6MTczOTAwODUzOSwicGF0aCI6Ii85MzcyNzUyMS8yOTMyOTE5OTQtMjU4OTg4ZjMtODdhYi00NzNhLTg0NzAtMDkzZmUyMjY0NDQ3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDA5NTUzOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTExMDFmMjdlYmE5ODlhZGQyZjFhYjFlZmEyMzUzNWJkMTAzZDk3ZWFlZTQ1NGY4OWQwOWViMzcyYjRkZTFiMGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.9qiS7F01F2dpX-mwfFW1BMFAgap07UBcfKQhU55usGI)
Here is the text: c:\Users\memgpt\connectors\db.py:47: SAWarning: This declarative base already contains a class with the same class name and module name as memgpt.connectors.db.Memgpt_agent_testing_userModel, and will be replaced in the string-lookup table.
Model = type(class_name, (PassageModel,), {"tablename": table_name, "table_args": {"extend_existing": True}})
Please describe your setup
Here is my code:
The text was updated successfully, but these errors were encountered: