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}')
|
logger.info(f'Log level is {l}')
|
||||||
del 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
|
# Need the logger to be initalized for this
|
||||||
logger.info('Running in local mode, OpenAI API key not required.')
|
logger.info('Running in local mode, OpenAI API key not required.')
|
||||||
openai.api_key = 'abc123'
|
openai.api_key = 'abc123'
|
||||||
|
@ -173,7 +173,7 @@ async def main():
|
||||||
logger.error(f'Ratelimited, sleeping {wait}s...')
|
logger.error(f'Ratelimited, sleeping {wait}s...')
|
||||||
time.sleep(wait)
|
time.sleep(wait)
|
||||||
except:
|
except:
|
||||||
logger.error('Could not parse M_LIMIT_EXCEEDED')
|
logger.error(f'Could not parse M_LIMIT_EXCEEDED: {login_response}')
|
||||||
else:
|
else:
|
||||||
logger.error(f'Failed to login, retrying: {login_response}')
|
logger.error(f'Failed to login, retrying: {login_response}')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
|
@ -9,6 +9,7 @@ from nio import LoginResponse
|
||||||
|
|
||||||
logger = logging.getLogger('MatrixGPT')
|
logger = logging.getLogger('MatrixGPT')
|
||||||
|
|
||||||
|
|
||||||
class MatrixNioGPTHelper:
|
class MatrixNioGPTHelper:
|
||||||
"""
|
"""
|
||||||
A simple wrapper class for common matrix-nio actions.
|
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)
|
Path(self.store_path).mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
self.device_name = device_name
|
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]:
|
async def login(self) -> tuple[bool, LoginError] | tuple[bool, LoginResponse | None]:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue