langchain_experimental.generative_agents.generative_agent.GenerativeAgent¶

class langchain_experimental.generative_agents.generative_agent.GenerativeAgent[source]¶

Bases: BaseModel

Agent as a character with memory and innate characteristics.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param age: Optional[int] = None¶

The optional age of the character.

param daily_summaries: List[str] [Optional]¶

Summary of the events in the plan that the agent took.

param last_refreshed: datetime [Optional]¶

The last time the character’s summary was regenerated.

param llm: BaseLanguageModel [Required]¶

The underlying language model.

param memory: GenerativeAgentMemory [Required]¶

The memory object that combines relevance, recency, and ‘importance’.

param name: str [Required]¶

The character’s name.

param status: str [Required]¶

The traits of the character you wish not to change.

param summary: str = ''¶

Stateful self-summary generated via reflection on the character’s memory.

param summary_refresh_seconds: int = 3600¶

How frequently to re-generate the summary.

param traits: str = 'N/A'¶

Permanent traits to ascribe to the character.

param verbose: bool = False¶
chain(prompt: PromptTemplate) LLMChain[source]¶

Create a chain with the same settings as the agent.

Parameters

prompt (PromptTemplate) –

Return type

LLMChain

generate_dialogue_response(observation: str, now: Optional[datetime] = None) Tuple[bool, str][source]¶

React to a given observation.

Parameters
  • observation (str) –

  • now (Optional[datetime]) –

Return type

Tuple[bool, str]

generate_reaction(observation: str, now: Optional[datetime] = None) Tuple[bool, str][source]¶

React to a given observation.

Parameters
  • observation (str) –

  • now (Optional[datetime]) –

Return type

Tuple[bool, str]

get_full_header(force_refresh: bool = False, now: Optional[datetime] = None) str[source]¶

Return a full header of the agent’s status, summary, and current time.

Parameters
  • force_refresh (bool) –

  • now (Optional[datetime]) –

Return type

str

get_summary(force_refresh: bool = False, now: Optional[datetime] = None) str[source]¶

Return a descriptive summary of the agent.

Parameters
  • force_refresh (bool) –

  • now (Optional[datetime]) –

Return type

str

Summarize memories that are most relevant to an observation.

Parameters

observation (str) –

Return type

str