Reduce timeouts, introduce ignore-channels, fix the fix functions.
This commit is contained in:
parent
a503ee405c
commit
e6d13afcca
@ -137,7 +137,7 @@ class AIResponder(object):
|
|||||||
return answer
|
return answer
|
||||||
messages = [{"role": "system", "content": self.config["fix-description"]},
|
messages = [{"role": "system", "content": self.config["fix-description"]},
|
||||||
{"role": "user", "content": answer}]
|
{"role": "user", "content": answer}]
|
||||||
for _ in range(4):
|
for _ in range(3):
|
||||||
try:
|
try:
|
||||||
result = await openai.ChatCompletion.acreate(model=self.config["fix-model"],
|
result = await openai.ChatCompletion.acreate(model=self.config["fix-model"],
|
||||||
messages=messages,
|
messages=messages,
|
||||||
@ -147,7 +147,7 @@ class AIResponder(object):
|
|||||||
start, end = response.find("```"), response.rfind("```")
|
start, end = response.find("```"), response.rfind("```")
|
||||||
if start == -1 or end == -1 or (start + 3) >= end:
|
if start == -1 or end == -1 or (start + 3) >= end:
|
||||||
return answer
|
return answer
|
||||||
response = response[start + 3, end]
|
response = response[start + 3:end]
|
||||||
logging.info(f"fixed answer:\n{pformat(response)}")
|
logging.info(f"fixed answer:\n{pformat(response)}")
|
||||||
return response
|
return response
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
@ -167,7 +167,7 @@ class AIResponder(object):
|
|||||||
limit = self.config["history-limit"]
|
limit = self.config["history-limit"]
|
||||||
if self.short_path(message, limit):
|
if self.short_path(message, limit):
|
||||||
return AIResponse(None, False, None, None, False)
|
return AIResponse(None, False, None, None, False)
|
||||||
for _ in range(14):
|
for _ in range(5):
|
||||||
messages = self._message(message, limit)
|
messages = self._message(message, limit)
|
||||||
logging.info(f"try to send this messages:\n{pformat(messages)}")
|
logging.info(f"try to send this messages:\n{pformat(messages)}")
|
||||||
answer, limit = await self._acreate(messages, limit)
|
answer, limit = await self._acreate(messages, limit)
|
||||||
|
|||||||
@ -85,7 +85,10 @@ class FjerkroaBot(commands.Bot):
|
|||||||
channel_name = str(channel.name)
|
channel_name = str(channel.name)
|
||||||
except Exception:
|
except Exception:
|
||||||
channel_name = str(channel.id)
|
channel_name = str(channel.id)
|
||||||
logging.info(f"handle message {str(message)} for channel {channel_name}")
|
if channel_name in self.config.get('ignore-channels', []):
|
||||||
|
logging.info(f"ignore message {repr(message)} for channel {channel_name}")
|
||||||
|
return
|
||||||
|
logging.info(f"handle message {repr(message)} for channel {channel_name}")
|
||||||
if channel_name in self.aichannels:
|
if channel_name in self.aichannels:
|
||||||
airesponder = self.aichannels[channel_name]
|
airesponder = self.aichannels[channel_name]
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user