Skip to content

Commit

Permalink
🔧 refactor: update default API tool model to "gpt-4o-mini" in credent…
Browse files Browse the repository at this point in the history
…ial components
  • Loading branch information
sudoskys committed Sep 13, 2024
1 parent 9ad0935 commit 65d0591
Show file tree
Hide file tree
Showing 3 changed files with 477 additions and 427 deletions.
2 changes: 1 addition & 1 deletion .nerve.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
contributor = "e35facd9-3bfa-48cd-9a95-ce72d24c3fcf"
contributor = "b4e0cd99-289b-4586-992c-6f159c436101"
# https://github.com/LlmKira/contributor/blob/main/.nerve.toml

language = "English"
Expand Down
16 changes: 7 additions & 9 deletions llmkira/extra/voice_hook.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from fast_langdetect import parse_sentence
from fast_langdetect import detect_multilingual
from loguru import logger

from llmkira.extra.voice import request_cn, request_en
Expand All @@ -13,21 +13,19 @@

def check_string(text):
"""
检查字符串是否符合要求
检查字符串是否 TTS 可以处理
:param text: 字符串
:return: 是否符合要求
"""
parsed_text = parse_sentence(text)
parsed_text = detect_multilingual(text)
if not parsed_text:
return False
lang_kinds = []
for lang in parsed_text:
if lang.get("lang", "RU") not in ["ZH", "EN"]:
return False
lang_kinds.append(lang.get("lang"))
lang_kinds.append(lang.get("lang", "ru"))
limit = 200
if len(set(lang_kinds)) == 1:
if lang_kinds[0] in ["EN"]:
if lang_kinds[0] in ["en"]:
limit = 500
if "\n\n" in text or text.count("\n") > 3 or len(text) > limit or "```" in text:
return False
Expand Down Expand Up @@ -59,7 +57,7 @@ async def hook_run(self, *args, **kwargs):
for message in messages:
if not check_string(message.text):
return args, kwargs
parsed_text = parse_sentence(message.text)
parsed_text = detect_multilingual(message.text)
if not parsed_text:
return args, kwargs
lang_kinds = []
Expand All @@ -68,7 +66,7 @@ async def hook_run(self, *args, **kwargs):
reecho_api_key = await EnvManager(locate.uid).get_env(
"REECHO_VOICE_KEY", None
)
if (len(set(lang_kinds)) == 1) and (lang_kinds[0] in ["EN"]):
if (len(set(lang_kinds)) == 1) and (lang_kinds[0] in ["en"]):
voice_data = await request_en(message.text)
else:
voice_data = await request_cn(
Expand Down
Loading

0 comments on commit 65d0591

Please sign in to comment.