added verbose logging config

This commit is contained in:
Rudis Muiznieks 2025-04-03 08:11:07 -05:00
parent c115baa705
commit 10c4de4f52
Signed by: rudism
GPG key ID: CABF2F86EF7884F9
3 changed files with 16 additions and 1 deletions

View file

@ -28,6 +28,8 @@ If you are a Kagi Professional or Kagi Ultimate subscriber, you can use the sess
}
```
You can add `"verbose": true` to your settings to print raw responses from Kagi to the skills log.
### Usage
The skill should catch all unrecognized utterances and pass those directly to FastGPT, then read the answer. Best attempt has been made to strip the response of formatting and references. If it doesn't respond you can check the skill logs for possible clues as to why (usually at `~/.local/state/mycroft/skills.log`).

View file

@ -24,6 +24,7 @@ class KagiSkill(FallbackSkill):
self.register_fallback(self.handle_fallback_kagi, 80)
def handle_fallback_kagi(self, message):
self.verbose = self.settings.get("verbose", False)
if "kagiSession" in self.settings:
return self.get_using_session(message)
elif "kagiApiKey" in self.settings:
@ -48,14 +49,20 @@ class KagiSkill(FallbackSkill):
timeout=(3, 10))
dirty_response = None
for event in client:
if self.verbose:
self.log.info(f'received data: {event.data}')
if event.data == '"[DONE]"':
break
dirty_response = event.data
if dirty_response is None:
self.log.error('bad session response from kagi')
return False
if self.verbose:
self.log.info(f'using final payload: {dirty_response}')
clean_response = self.clean_session_string(dirty_response)
self.speak(clean_response)
if self.verbose:
self.log.info(f'cleaned up response: {clean_response}')
return True
except Exception as e:
self.log.error(f'error fetching kagi session response: {str(e)}')
@ -81,12 +88,18 @@ class KagiSkill(FallbackSkill):
data=js_data,
headers=header_content,
verify=False)
if self.verbose:
self.log.info(f'kagi api response: {response.text}')
json_data = json.loads(response.text)
dirty_response = self.get_api_response(json_data)
if dirty_response is None:
self.log.error('bad api response from kagi')
return False
if self.verbose:
self.log.info(f'using response text: {dirty_response}')
clean_response = self.clean_api_string(dirty_response)
if self.verbose:
self.log.info(f'cleaned up response: {clean_response}')
self.speak(clean_response)
return True
except Exception as e:

View file

@ -4,7 +4,7 @@ import os
from os import walk, path
PYPI_NAME = "skill-ovos-fallback-kagi" # pip install PYPI_NAME
VERSION = "0.1.5"
VERSION = "0.1.6"
URL = f"https://code.sitosis.com/rudism/{PYPI_NAME}"
SKILL_CLAZZ = "KagiSkill" # needs to match __init__.py class name