Skip to main content
`Ctrl`+`K`

# Experimental Modules

This module contains experimental modules and reproductions of existing work using LangChain primitives.

## Autonomous Agents

Here, we document the BabyAGI and AutoGPT classes from the langchain.experimental module.

class langchain.experimental.BabyAGI(*, memory: Optional[langchain.schema.BaseMemory] = None, callback_manager: langchain.callbacks.base.BaseCallbackManager = None, verbose: bool = None, task_list: collections.deque = None, task_creation_chain: langchain.chains.base.Chain, task_prioritization_chain: langchain.chains.base.Chain, execution_chain: langchain.chains.base.Chain, task_id_counter: int = 1, vectorstore: langchain.vectorstores.base.VectorStore, max_iterations: Optional[int] = None)

  Controller model for the BabyAGI agent.

  model Config

    Configuration for this pydantic object.

    arbitrary_types_allowed = True
  execute_task(objective: str, task: str, k: int = 5) → str

    Execute a task.

  classmethod from_llm(llm: langchain.schema.BaseLanguageModel, vectorstore: langchain.vectorstores.base.VectorStore, verbose: bool = False, task_execution_chain: Optional[langchain.chains.base.Chain] = None, **kwargs: Dict[str, Any]) → langchain.experimental.autonomous_agents.baby_agi.baby_agi.BabyAGI

    Initialize the BabyAGI Controller.

  get_next_task(result: str, task_description: str, objective: str) → List[Dict]

    Get the next task.

  property input_keys: List[str]

    Input keys this chain expects.

  property output_keys: List[str]

    Output keys this chain expects.

  prioritize_tasks(this_task_id: int, objective: str) → List[Dict]

    Prioritize tasks.

class langchain.experimental.AutoGPT(ai_name: str, memory: langchain.vectorstores.base.VectorStoreRetriever, chain: langchain.chains.llm.LLMChain, output_parser: langchain.experimental.autonomous_agents.autogpt.output_parser.BaseAutoGPTOutputParser, tools: List[langchain.tools.base.BaseTool], feedback_tool: Optional[langchain.tools.human.tool.HumanInputRun] = None)

  Agent class for interacting with Auto-GPT.

## Generative Agents

Here, we document the GenerativeAgent and GenerativeAgentMemory classes from the langchain.experimental module.

class langchain.experimental.GenerativeAgent(*, name: str, age: Optional[int] = None, traits: str = 'N/A', status: str, memory: langchain.experimental.generative_agents.memory.GenerativeAgentMemory, llm: langchain.schema.BaseLanguageModel, verbose: bool = False, summary: str = '', summary_refresh_seconds: int = 3600, last_refreshed: datetime.datetime = None, daily_summaries: List[str] = None)

  A character with memory and innate characteristics.

  model Config

    Configuration for this pydantic object.

    arbitrary_types_allowed = True
  field age: Optional[int] = None

    The optional age of the character.

  field daily_summaries: List[str] [Optional]

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

  generate_dialogue_response(observation: str) → Tuple[bool, str]

    React to a given observation.

  generate_reaction(observation: str) → Tuple[bool, str]

    React to a given observation.

  get_full_header(force_refresh: bool = False) → str

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

  get_summary(force_refresh: bool = False) → str

    Return a descriptive summary of the agent.

  field last_refreshed: datetime.datetime [Optional]

    The last time the character’s summary was regenerated.

  field llm: langchain.schema.BaseLanguageModel [Required]

    The underlying language model.

  field memory: langchain.experimental.generative_agents.memory.GenerativeAgentMemory [Required]

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

  field name: str [Required]

    The character’s name.

  field status: str [Required]

    The traits of the character you wish not to change.

  summarize_related_memories(observation: str) → str

    Summarize memories that are most relevant to an observation.

  field summary: str = ''

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

  field summary_refresh_seconds: int = 3600

    How frequently to re-generate the summary.

  field traits: str = 'N/A'

    Permanent traits to ascribe to the character.

class langchain.experimental.GenerativeAgentMemory(*, llm: langchain.schema.BaseLanguageModel, memory_retriever: langchain.retrievers.time_weighted_retriever.TimeWeightedVectorStoreRetriever, verbose: bool = False, reflection_threshold: Optional[float] = None, current_plan: List[str] = [], importance_weight: float = 0.15, aggregate_importance: float = 0.0, max_tokens_limit: int = 1200, queries_key: str = 'queries', most_recent_memories_token_key: str = 'recent_memories_token', add_memory_key: str = 'add_memory', relevant_memories_key: str = 'relevant_memories', relevant_memories_simple_key: str = 'relevant_memories_simple', most_recent_memories_key: str = 'most_recent_memories')
  add_memory(memory_content: str) → List[str]

    Add an observation or memory to the agent’s memory.

  field aggregate_importance: float = 0.0

    Track the sum of the ‘importance’ of recent memories.

    Triggers reflection when it reaches reflection_threshold.

  clear() → None

    Clear memory contents.

  field current_plan: List[str] = []

    The current plan of the agent.

  fetch_memories(observation: str) → List[langchain.schema.Document]

    Fetch related memories.

  field importance_weight: float = 0.15

    How much weight to assign the memory importance.

  field llm: langchain.schema.BaseLanguageModel [Required]

    The core language model.

  load_memory_variables(inputs: Dict[str, Any]) → Dict[str, str]

    Return key-value pairs given the text input to the chain.

  field memory_retriever: langchain.retrievers.time_weighted_retriever.TimeWeightedVectorStoreRetriever [Required]

    The retriever to fetch related memories.

  property memory_variables: List[str]

    Input keys this memory class will load dynamically.

  pause_to_reflect() → List[str]

    Reflect on recent observations and generate ‘insights’.

  field reflection_threshold: Optional[float] = None

    When aggregate_importance exceeds reflection_threshold, stop to reflect.

  save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) → None

    Save the context of this model run to memory.