made session read timeout configurable

This commit is contained in:
Rudis Muiznieks 2025-04-03 08:34:58 -05:00
parent ccae0fe238
commit 25f672f7e5
Signed by: rudism
GPG key ID: CABF2F86EF7884F9
3 changed files with 5 additions and 2 deletions

View file

@ -28,6 +28,8 @@ If you are a Kagi Professional or Kagi Ultimate subscriber, you can use the sess
}
```
By default the session-based API will wait up to 10 seconds for a complete response, but this may not be long enough for longer answers that trigger searches, so you can increase that by setting a `timeout` value to a different number of seconds. The catch is that if the session API fails to send a `[DONE]` event then the skill will hang for the full duration before passing the utterance to the next fallback skill.
You can add `"verbose": true` to your settings to print raw responses from Kagi to the skills log.
### Usage

View file

@ -37,6 +37,7 @@ class KagiSkill(FallbackSkill):
return False # not configured yet
def get_using_session(self, message):
self.timeout = self.settings.get("timeout", 10)
session_cookie = self.settings.get("kagiSession", "")
header_content = {
'Accept': 'text/event-stream',
@ -46,7 +47,7 @@ class KagiSkill(FallbackSkill):
try:
client = sseclient.SSEClient(read_url,
headers=header_content,
timeout=(3, 10))
timeout=(3, self.timeout))
dirty_response = None
for event in client:
if self.verbose:

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.7"
VERSION = "0.1.8"
URL = f"https://code.sitosis.com/rudism/{PYPI_NAME}"
SKILL_CLAZZ = "KagiSkill" # needs to match __init__.py class name