Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(): add greeting for qwen LLM #277

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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