fix: various fixes + make sure to save agent on creation to avoid missing agent_state.state entries (#877)

This commit is contained in:
Charles Packer
2024-01-20 17:28:39 -08:00
committed by GitHub
parent 030a1c2435
commit 6094726dfe
3 changed files with 5 additions and 3 deletions

View File

@@ -28,7 +28,7 @@ from memgpt.agent import Agent
from memgpt.embeddings import embedding_model
from memgpt.server.constants import WS_DEFAULT_PORT, REST_DEFAULT_PORT
from memgpt.data_types import AgentState, LLMConfig, EmbeddingConfig, User
from memgpt.metadata import MetadataStore
from memgpt.metadata import MetadataStore, save_agent
from memgpt.migrate import migrate_all_agents, migrate_all_sources
@@ -604,6 +604,7 @@ def run(
agent_state=agent_state,
interface=interface,
)
save_agent(agent=memgpt_agent, ms=ms)
except ValueError as e:
# TODO(swooders) what's the equivalent cleanup code for the new DB refactor?
typer.secho(f"Failed to create agent from provided information:\n{e}", fg=typer.colors.RED)
@@ -623,7 +624,7 @@ def run(
# except:
# typer.secho(f"Failed to delete agent directory during cleanup:\n{e}", fg=typer.colors.RED)
sys.exit(1)
typer.secho(f"🎉 Created new agent '{agent_state.name}'", fg=typer.colors.GREEN)
typer.secho(f"🎉 Created new agent '{agent_state.name}' (id={agent_state.id})", fg=typer.colors.GREEN)
# pretty print agent config
# printd(json.dumps(vars(agent_config), indent=4, sort_keys=True, ensure_ascii=JSON_ENSURE_ASCII))

View File

@@ -64,7 +64,7 @@ class LLMConfigColumn(TypeDecorator):
return value
def process_result_value(self, value, dialect):
print("GET VALUE", value)
# print("GET VALUE", value)
if value:
return LLMConfig(**value)
return value

View File

@@ -611,6 +611,7 @@ class SyncServer(LockingServer):
logger.debug(f"Attempting to create agent from agent_state:\n{agent_state}")
try:
agent = presets.create_agent_from_preset(agent_state=agent_state, interface=interface)
save_agent(agent=agent, ms=self.ms)
# FIXME: this is a hacky way to get the system prompts injected into agent into the DB
# self.ms.update_agent(agent.agent_state)