forked from Archives/langchain
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
1.0 KiB
Python
25 lines
1.0 KiB
Python
from langchain import LLMChain, PromptTemplate
|
|
from langchain.schema import BaseLanguageModel
|
|
|
|
|
|
class TaskPrioritizationChain(LLMChain):
|
|
"""Chain to prioritize tasks."""
|
|
|
|
@classmethod
|
|
def from_llm(cls, llm: BaseLanguageModel, verbose: bool = True) -> LLMChain:
|
|
"""Get the response parser."""
|
|
task_prioritization_template = (
|
|
"You are a task prioritization AI tasked with cleaning the formatting of "
|
|
"and reprioritizing the following tasks: {task_names}."
|
|
" Consider the ultimate objective of your team: {objective}."
|
|
" Do not remove any tasks. Return the result as a numbered list, like:"
|
|
" #. First task"
|
|
" #. Second task"
|
|
" Start the task list with number {next_task_id}."
|
|
)
|
|
prompt = PromptTemplate(
|
|
template=task_prioritization_template,
|
|
input_variables=["task_names", "next_task_id", "objective"],
|
|
)
|
|
return cls(prompt=prompt, llm=llm, verbose=verbose)
|