From 7e6eb00734f48c8be4cbb58159e2b8e93d7c5f10 Mon Sep 17 00:00:00 2001 From: tomasliu <67892682+tomasliu-agora@users.noreply.github.com> Date: Tue, 16 Jul 2024 22:33:39 +0800 Subject: [PATCH] Dev/fix cosy bug (#105) * fix cosy interrupt and safe exit * fix init --- agents/addon/extension/cosy_tts/main.py | 1 + .../addon/extension/qwen_llm_python/main.py | 4 +- agents/manifest.json.qwen.example | 205 ++++++++++++++++++ 3 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 agents/manifest.json.qwen.example diff --git a/agents/addon/extension/cosy_tts/main.py b/agents/addon/extension/cosy_tts/main.py index e9661f72..0bc2e52f 100644 --- a/agents/addon/extension/cosy_tts/main.py +++ b/agents/addon/extension/cosy_tts/main.py @@ -107,6 +107,7 @@ def __init__(self, name: str): self.tts = None self.callback = None self.format = None + self.outdateTs = datetime.now() self.stopped = False self.thread = None diff --git a/agents/addon/extension/qwen_llm_python/main.py b/agents/addon/extension/qwen_llm_python/main.py index 41a0cab0..e7c8da2c 100644 --- a/agents/addon/extension/qwen_llm_python/main.py +++ b/agents/addon/extension/qwen_llm_python/main.py @@ -96,7 +96,7 @@ def call_with_stream(self, rte: Rte, ts :datetime.time, inputText: str, messages messages.append({'role':'user', 'content':inputText}) logger.info("before call %s %s", messages, ts) - responses = dashscope.Generation.call("qwen-max", + responses = dashscope.Generation.call(self.model, messages=messages, result_format='message', # set the result to be "message" format. stream=True, # set streaming output @@ -152,7 +152,7 @@ def on_init( def on_start(self, rte: Rte) -> None: logger.info("QWenLLMExtension on_start") self.api_key = rte.get_property_string("api_key") - self.mode = rte.get_property_string("model") + self.model = rte.get_property_string("model") self.prompt = rte.get_property_string("prompt") self.max_history = rte.get_property_int("max_memory_length") diff --git a/agents/manifest.json.qwen.example b/agents/manifest.json.qwen.example new file mode 100644 index 00000000..3361faa3 --- /dev/null +++ b/agents/manifest.json.qwen.example @@ -0,0 +1,205 @@ +{ + "type": "app", + "name": "astra_agents", + "version": "0.2.0", + "language": "python", + "dependencies": [ + { + "type": "extension_group", + "name": "default_extension_group", + "version": "0.2.0" + }, + { + "type": "extension", + "name": "agora_rtc", + "version": "0.2.0-alpha" + }, + { + "type": "system", + "name": "rte_runtime_python", + "version": "0.2.0" + } + ], + "predefined_graphs": [ + { + "name": "astra_agents", + "auto_start": true, + "nodes": [ + { + "type": "extension", + "extension_group": "default", + "addon": "agora_rtc", + "name": "agora_rtc", + "property": { + "app_id": "", + "token": "", + "channel": "astra_agents_test", + "stream_id": 1234, + "remote_stream_id": 123, + "subscribe_audio": true, + "publish_audio": true, + "publish_data": true, + "enable_agora_asr": true, + "agora_asr_vendor_name": "microsoft", + "agora_asr_language": "en-US", + "agora_asr_vendor_key": "", + "agora_asr_vendor_region": "", + "agora_asr_session_control_file_path": "session_control.conf" + } + }, + { + "type": "extension", + "extension_group": "llm", + "addon": "qwen_llm_python", + "name": "qwen_llm", + "property": { + "api_key": "", + "model": "qwen-max", + "max_tokens": 512, + "prompt": "", + "max_memory_length": 10 + } + }, + { + "type": "extension", + "extension_group": "tts", + "addon": "cosy_tts", + "name": "cosy_tts", + "property": { + "api_key": "", + "model": "cosyvoice-v1", + "voice": "longxiaochun", + "sample_rate": 16000 + } + }, + { + "type": "extension", + "extension_group": "default", + "addon": "interrupt_detector_python", + "name": "interrupt_detector" + }, + { + "type": "extension_group", + "addon": "default_extension_group", + "name": "default" + }, + { + "type": "extension_group", + "addon": "default_extension_group", + "name": "llm" + }, + { + "type": "extension_group", + "addon": "default_extension_group", + "name": "tts" + } + ], + "connections": [ + { + "extension_group": "default", + "extension": "agora_rtc", + "data": [ + { + "name": "text_data", + "dest": [ + { + "extension_group": "default", + "extension": "interrupt_detector" + } + ] + } + ], + "pcm_frame": [ + { + "name": "pcm_frame", + "dest": [ + { + "extension_group": "llm", + "extension": "qwen_llm" + } + ] + } + ] + }, + { + "extension_group": "default", + "extension": "interrupt_detector", + "cmd": [ + { + "name": "flush", + "dest": [ + { + "extension_group": "llm", + "extension": "qwen_llm" + } + ] + } + ], + "data": [ + { + "name": "text_data", + "dest": [ + { + "extension_group": "llm", + "extension": "qwen_llm" + } + ] + } + ] + }, + { + "extension_group": "llm", + "extension": "qwen_llm", + "data": [ + { + "name": "text_data", + "dest": [ + { + "extension_group": "tts", + "extension": "cosy_tts" + } + ] + } + ], + "cmd": [ + { + "name": "flush", + "dest": [ + { + "extension_group": "tts", + "extension": "cosy_tts" + } + ] + } + ] + }, + { + "extension_group": "tts", + "extension": "cosy_tts", + "pcm_frame": [ + { + "name": "pcm_frame", + "dest": [ + { + "extension_group": "default", + "extension": "agora_rtc" + } + ] + } + ], + "cmd": [ + { + "name": "flush", + "dest": [ + { + "extension_group": "default", + "extension": "agora_rtc" + } + ] + } + ] + } + ] + } + ] +}