forked from SantanderAI/llm_bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqwen_example.py
More file actions
40 lines (30 loc) · 865 Bytes
/
Copy pathqwen_example.py
File metadata and controls
40 lines (30 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Copyright (c) 2026 Santander Group
# SPDX-License-Identifier: Apache-2.0
"""Alibaba Qwen provider.
Requires:
pip install "llm-bridge[qwen]"
export DASHSCOPE_API_KEY=...
Run:
python examples/qwen_example.py
"""
import os
from llm_bridge import create_llm
def main() -> None:
if not os.environ.get("DASHSCOPE_API_KEY"):
print("Set DASHSCOPE_API_KEY to run this example.")
return
try:
llm = create_llm(
{
"provider": "qwen",
"model": os.environ.get("QWEN_MODEL", "qwen-plus"),
}
)
except ImportError as exc:
print(exc)
return
resp = llm.complete("Say hello in one short sentence.", system="You are friendly and concise.")
print(resp.content)
print("tokens:", resp.total_tokens)
if __name__ == "__main__":
main()