mirror of
https://github.com/IntelligenzaArtificiale/Free-Auto-GPT.git
synced 2026-06-02 06:14:36 +02:00
21 lines
817 B
Python
21 lines
817 B
Python
from langchain import LLMChain, PromptTemplate
|
|
from langchain.base_language import BaseLanguageModel
|
|
|
|
|
|
class TaskExecutionChain(LLMChain):
|
|
"""Chain to execute tasks."""
|
|
|
|
@classmethod
|
|
def from_llm(cls, llm: BaseLanguageModel, verbose: bool = True) -> LLMChain:
|
|
"""Get the response parser."""
|
|
execution_template = (
|
|
"Can you help me to performs one task based on the following objective: "
|
|
"{objective}."
|
|
"Take into account these previously completed tasks: {context}."
|
|
"Can you perform this task? Your task: {task}. Response:"
|
|
)
|
|
prompt = PromptTemplate(
|
|
template=execution_template,
|
|
input_variables=["objective", "context", "task"],
|
|
)
|
|
return cls(prompt=prompt, llm=llm, verbose=verbose) |