Merge pull request #13 from S-Bryce/patch-2

Add Support for Koboldcpp
This commit is contained in:
Lex-au 2025-03-23 18:27:49 +11:00 committed by GitHub
commit 088363eca5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -273,12 +273,14 @@ def generate_tokens_from_api(prompt: str, voice: str = DEFAULT_VOICE, temperatur
try:
data = json.loads(data_str)
if 'choices' in data and len(data['choices']) > 0:
token_text = data['choices'][0].get('text', '')
token_counter += 1
perf_monitor.add_tokens()
if token_text:
yield token_text
token_chunk = data['choices'][0].get('text', '')
for token_text in token_chunk.split('>'):
token_text = f'{token_text}>'
token_counter += 1
perf_monitor.add_tokens()
if token_text:
yield token_text
except json.JSONDecodeError as e:
print(f"Error decoding JSON: {e}")
continue