feat: added persona/human_name fields to Preset (#1134)

This commit is contained in:
Charles Packer
2024-03-11 16:33:05 -07:00
committed by GitHub
parent c508acb9dc
commit 1f192be107
5 changed files with 14 additions and 4 deletions

View File

@@ -199,8 +199,8 @@ class Agent(object):
init_agent_state = AgentState(
name=name if name else create_random_username(),
user_id=created_by,
persona=preset.persona,
human=preset.human,
persona=preset.persona_name,
human=preset.human_name,
llm_config=llm_config,
embedding_config=embedding_config,
preset=preset.name, # TODO link via preset.id instead of name?

View File

@@ -668,8 +668,8 @@ def run(
preset_obj.human = ms.get_human(human, user.id).text
preset_obj.persona = ms.get_persona(persona, user.id).text
typer.secho(f"-> 🤖 Using persona profile '{preset_obj.persona}'", fg=typer.colors.WHITE)
typer.secho(f"-> 🧑 Using human profile '{preset_obj.human}'", fg=typer.colors.WHITE)
typer.secho(f"-> 🤖 Using persona profile: '{preset_obj.persona_name}'", fg=typer.colors.WHITE)
typer.secho(f"-> 🧑 Using human profile: '{preset_obj.human_name}'", fg=typer.colors.WHITE)
memgpt_agent = Agent(
interface=interface(),

View File

@@ -543,7 +543,9 @@ class Preset(BaseModel):
created_at: datetime = Field(default_factory=datetime.now, description="The unix timestamp of when the preset was created.")
system: str = Field(..., description="The system prompt of the preset.")
persona: str = Field(default=get_persona_text(DEFAULT_PERSONA), description="The persona of the preset.")
persona_name: Optional[str] = Field(None, description="The name of the persona of the preset.")
human: str = Field(default=get_human_text(DEFAULT_HUMAN), description="The human of the preset.")
human_name: Optional[str] = Field(None, description="The name of the human of the preset.")
functions_schema: List[Dict] = Field(..., description="The functions schema of the preset.")
# functions: List[str] = Field(..., description="The functions of the preset.") # TODO: convert to ID
# sources: List[str] = Field(..., description="The sources of the preset.") # TODO: convert to ID

View File

@@ -270,7 +270,9 @@ class PresetModel(Base):
description = Column(String)
system = Column(String)
human = Column(String)
human_name = Column(String, nullable=False)
persona = Column(String)
persona_name = Column(String, nullable=False)
preset = Column(String)
created_at = Column(DateTime(timezone=True), server_default=func.now())
@@ -288,6 +290,8 @@ class PresetModel(Base):
system=self.system,
human=self.human,
persona=self.persona,
human_name=self.human_name,
persona_name=self.persona_name,
preset=self.preset,
created_at=self.created_at,
functions_schema=self.functions_schema,

View File

@@ -52,6 +52,8 @@ def create_preset_from_file(filename: str, name: str, user_id: uuid.UUID, ms: Me
system=gpt_system.get_system_text(preset_system_prompt),
persona=get_persona_text(DEFAULT_PERSONA),
human=get_human_text(DEFAULT_HUMAN),
persona_name=DEFAULT_PERSONA,
human_name=DEFAULT_HUMAN,
functions_schema=functions_schema,
)
ms.create_preset(preset)
@@ -79,7 +81,9 @@ def add_default_presets(user_id: uuid.UUID, ms: MetadataStore):
name=preset_name,
system=gpt_system.get_system_text(preset_system_prompt),
persona=get_persona_text(DEFAULT_PERSONA),
persona_name=DEFAULT_PERSONA,
human=get_human_text(DEFAULT_HUMAN),
human_name=DEFAULT_HUMAN,
functions_schema=functions_schema,
)
ms.create_preset(preset)