feat: Support Alibaba Bailian supplier qwen3 model#3020
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| model.invoke([HumanMessage(content=gettext('Hello'))]) | ||
| except Exception as e: | ||
| traceback.print_exc() | ||
| if isinstance(e, AppApiException): |
There was a problem hiding this comment.
The code provided has a few minor improvements that can be made:
- Handling Stream Mode: The
model.streammethod is only being called whenmodel_params.get('stream')is truthy. - Explicitly Handling None Types: If
resin the stream mode returnsNone, it will not throw an exception but simply go to the next iteration of the loop.
Here's the updated code with these improvements included:
@@ -47,7 +47,12 @@
return False
try:
model = provider.get_model(model_type, model_name, model_credential, **model_params)
- model.invoke([HumanMessage(content=gettext('Hello'))])
+ if 'stream' in model_params and model_params['stream']:
+ for res in model.stream([HumanMessage(content=gettext('Hello'))]):
+ # Handle streaming output here, e.g., print(res)
+ pass
+ else:
+ model.invoke([HumanMessage(content=gettext('Hello'))])
except Exception as e:
traceback.print_exc()
if isinstance(e, AppApiException):Additionally, consider adding error handling around any operations within the stream loop or where res might be None.
feat: Support Alibaba Bailian supplier qwen3 model