qc on meta prompter

pull/59/head
Kye 1 year ago
parent 9628e0a10c
commit ba2c415e05

@ -108,7 +108,7 @@ class MetaPrompterAgent:
def get_new_instructions(self, meta_output): def get_new_instructions(self, meta_output):
"""Get New Instructions from the meta_output""" """Get New Instructions from the meta_output"""
delimiter = "Instructions: " delimiter = "Instructions: "
new_instructions = meta_output[meta_output.find(delimiter) + len(delimiter):] new_instructions = meta_output[meta_output.find(delimiter) + len(delimiter) :]
return new_instructions return new_instructions
def run(self, task: str): def run(self, task: str):
@ -121,17 +121,12 @@ class MetaPrompterAgent:
Returns: Returns:
str: The response from the agent str: The response from the agent
""" """
key_phrases = [ key_phrases = [self.success_phrase, self.failed_phrase]
self.success_phrase,
self.failed_phrase
]
for i in range(self.max_meta_iters): for i in range(self.max_meta_iters):
print(f"[Epsisode: {i+1}/{self.max_meta_iters}]") print(f"[Epsisode: {i+1}/{self.max_meta_iters}]")
chain = self.chain( chain = self.chain(memory=None)
memory=None
)
output = chain.predict(human_input=task) output = chain.predict(human_input=task)
@ -143,9 +138,7 @@ class MetaPrompterAgent:
if self.human_input: if self.human_input:
human_input = input() human_input = input()
if any( if any(phrase in human_input.lower() for phrase in key_phrases):
phrase in human_input.lower() for phrase in key_phrases
):
break break
output = chain.predict(human_input.lower) output = chain.predict(human_input.lower)
@ -155,7 +148,9 @@ class MetaPrompterAgent:
return return
meta_chain = self.initialize_meta_chain() meta_chain = self.initialize_meta_chain()
meta_output = meta_chain.predict(chat_history=self.get_chat_history(chain.memory)) meta_output = meta_chain.predict(
chat_history=self.get_chat_history(chain.memory)
)
print(f"Feedback: {meta_output}") print(f"Feedback: {meta_output}")
self.instructions = self.get_new_instructions(meta_output) self.instructions = self.get_new_instructions(meta_output)

Loading…
Cancel
Save