Fix image handling and do not react to bots or unchanged messages.
This commit is contained in:
@@ -37,7 +37,12 @@ class OpenAIResponder(AIResponder, LeonardoAIDrawMixIn):
|
||||
raise RuntimeError(f"Failed to generate image {repr(description)} after multiple retries")
|
||||
|
||||
async def chat(self, messages: List[Dict[str, Any]], limit: int) -> Tuple[Optional[Dict[str, Any]], int]:
|
||||
model = self.config["model"]
|
||||
if type(messages[-1]['content']) == str:
|
||||
model = self.config["model"]
|
||||
elif 'model-vision' in self.config:
|
||||
model = self.config["model-vision"]
|
||||
else:
|
||||
messages[-1]['content'] = messages[-1]['content'][0]['text']
|
||||
try:
|
||||
result = await openai_chat(self.client,
|
||||
model=model,
|
||||
@@ -118,7 +123,7 @@ class OpenAIResponder(AIResponder, LeonardoAIDrawMixIn):
|
||||
{'role': 'user', 'content': f'Here is my previous memory:\n```\n{memory}\n```\n\n'
|
||||
f'Here is my conversanion:\n```\n{message_user}: {question}\n\n{answer_user}: {answer}\n```\n\n'
|
||||
f'Please rewrite the memory in a way, that it contain the content mentioned in conversation. '
|
||||
f'The whole memory should not be too long, summarize if required. '
|
||||
f'Summarize the memory if required, try to keep important information. '
|
||||
f'Write just new memory data without any comments.'}]
|
||||
logging.info(f'Rewrite memory:\n{pp(messages)}')
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user