Source code for langchain_experimental.autonomous_agents.baby_agi.task_execution
from langchain.chains import LLMChain
from langchain_core.language_models import BaseLanguageModel
from langchain_core.prompts import PromptTemplate
[docs]class TaskExecutionChain(LLMChain):
"""η¨δΊζ§θ‘δ»»ε‘ηιΎεΌθ°η¨γ"""
[docs] @classmethod
def from_llm(cls, llm: BaseLanguageModel, verbose: bool = True) -> LLMChain:
"""θ·εεεΊθ§£ζε¨γ"""
execution_template = (
"You are an AI who performs one task based on the following objective: "
"{objective}."
"Take into account these previously completed tasks: {context}."
" Your task: {task}. Response:"
)
prompt = PromptTemplate(
template=execution_template,
input_variables=["objective", "context", "task"],
)
return cls(prompt=prompt, llm=llm, verbose=verbose)