Skip to content

Commit

Permalink
Dev/fix cosy bug (#105)
Browse files Browse the repository at this point in the history
* fix cosy interrupt and safe exit

* fix init
  • Loading branch information
tomasliu-agora authored Jul 16, 2024
1 parent 0956ada commit 7e6eb00
Show file tree
Hide file tree
Showing 3 changed files with 208 additions and 2 deletions.
1 change: 1 addition & 0 deletions agents/addon/extension/cosy_tts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions agents/addon/extension/qwen_llm_python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down
205 changes: 205 additions & 0 deletions agents/manifest.json.qwen.example
Original file line number Diff line number Diff line change
@@ -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": "<agora_appid>",
"token": "<agora_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": "<azure_stt_key>",
"agora_asr_vendor_region": "<azure_stt_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": "<qwen_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": "<qwen_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"
}
]
}
]
}
]
}
]
}

0 comments on commit 7e6eb00

Please sign in to comment.