Skip to content

Commit

Permalink
chore(): add greeting for qwen LLM (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshinexcode authored Sep 12, 2024
1 parent e030d2c commit 1b9ee9e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions agents/property.json
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@
"api_key": "$QWEN_API_KEY",
"model": "qwen-max",
"max_tokens": 512,
"greeting": "ASTRA agent connected. How can i help you today?",
"prompt": "",
"max_memory_length": 10
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from http import HTTPStatus
from .log import logger

DATA_OUT_TEXT_DATA_PROPERTY_TEXT = "text"
DATA_OUT_TEXT_DATA_PROPERTY_TEXT_END_OF_SEGMENT = "end_of_segment"

class QWenLLMExtension(Extension):
def __init__(self, name: str):
Expand Down Expand Up @@ -190,6 +192,18 @@ def on_start(self, ten: TenEnv) -> None:
self.model = ten.get_property_string("model")
self.prompt = ten.get_property_string("prompt")
self.max_history = ten.get_property_int("max_memory_length")
greeting = ten.get_property_string("greeting")

if greeting:
try:
output_data = Data.create("text_data")
output_data.set_property_string(DATA_OUT_TEXT_DATA_PROPERTY_TEXT, greeting)
output_data.set_property_bool(DATA_OUT_TEXT_DATA_PROPERTY_TEXT_END_OF_SEGMENT, True)
ten.send_data(output_data)
logger.info(f"greeting [{greeting}] sent")
except Exception as e:
logger.error(f"greeting [{greeting}] send failed, err: {e}")


dashscope.api_key = self.api_key
self.thread = threading.Thread(target=self.async_handle, args=[ten])
Expand Down

0 comments on commit 1b9ee9e

Please sign in to comment.