langchain_experimental.generative_agents.generative_agent.GenerativeAgent¶
- class langchain_experimental.generative_agents.generative_agent.GenerativeAgent(*, name: str, age: Optional[int] = None, traits: str = 'N/A', status: str, memory: GenerativeAgentMemory, llm: BaseLanguageModel, verbose: bool = False, summary: str = '', summary_refresh_seconds: int = 3600, last_refreshed: datetime = None, daily_summaries: List[str] = None)[source]¶
Bases:
BaseModelAn 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.datetime [Optional]¶
The last time the character’s summary was regenerated.
- param llm: langchain.schema.language_model.BaseLanguageModel [Required]¶
The underlying language model.
- param memory: langchain_experimental.generative_agents.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]¶
- generate_dialogue_response(observation: str, now: Optional[datetime] = None) Tuple[bool, str][source]¶
React to a given observation.
- generate_reaction(observation: str, now: Optional[datetime] = None) Tuple[bool, str][source]¶
React to a given observation.
- 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.
- get_summary(force_refresh: bool = False, now: Optional[datetime] = None) str[source]¶
Return a descriptive summary of the agent.
Summarize memories that are most relevant to an observation.