fix keyerror
This commit is contained in:
parent
b47e1af873
commit
d7d68f4d42
4
main.py
4
main.py
|
@ -104,7 +104,7 @@ async def main():
|
|||
logger.info(f'Log level is {l}')
|
||||
del l
|
||||
|
||||
if len(config_data['command'].keys()) == 1 and config_data['command'][list(config_data['command'].keys())[0]]['mode'] == 'local':
|
||||
if len(config_data['command'].keys()) == 1 and config_data['command'][list(config_data['command'].keys())[0]].get('mode') == 'local':
|
||||
# Need the logger to be initalized for this
|
||||
logger.info('Running in local mode, OpenAI API key not required.')
|
||||
openai.api_key = 'abc123'
|
||||
|
@ -173,7 +173,7 @@ async def main():
|
|||
logger.error(f'Ratelimited, sleeping {wait}s...')
|
||||
time.sleep(wait)
|
||||
except:
|
||||
logger.error('Could not parse M_LIMIT_EXCEEDED')
|
||||
logger.error(f'Could not parse M_LIMIT_EXCEEDED: {login_response}')
|
||||
else:
|
||||
logger.error(f'Failed to login, retrying: {login_response}')
|
||||
time.sleep(5)
|
||||
|
|
|
@ -9,6 +9,7 @@ from nio import LoginResponse
|
|||
|
||||
logger = logging.getLogger('MatrixGPT')
|
||||
|
||||
|
||||
class MatrixNioGPTHelper:
|
||||
"""
|
||||
A simple wrapper class for common matrix-nio actions.
|
||||
|
@ -30,7 +31,7 @@ class MatrixNioGPTHelper:
|
|||
Path(self.store_path).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
self.device_name = device_name
|
||||
self.client = AsyncClient(self.homeserver, self.user_id, config=self.client_config, store_path=self.store_path, device_id=device_id)
|
||||
self.client = AsyncClient(homeserver=self.homeserver, user=self.user_id, config=self.client_config, store_path=self.store_path, device_id=device_id)
|
||||
|
||||
async def login(self) -> tuple[bool, LoginError] | tuple[bool, LoginResponse | None]:
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue