27 lines
722 B
Python
27 lines
722 B
Python
import logging
|
||
|
||
from langchain_siliconflow import ChatSiliconFlow
|
||
import os
|
||
import dotenv
|
||
|
||
|
||
logging.basicConfig(
|
||
level=logging.INFO,
|
||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||
)
|
||
|
||
dotenv.load_dotenv()
|
||
|
||
## 设置环境变量
|
||
os.environ['SILICONFLOW_API_KEY'] = os.getenv("SILICONFLOW_API_KEY")
|
||
os.environ['SILICONFLOW_BASE_URL'] = os.getenv("SILICONFLOW_BASE_URL")
|
||
|
||
# 默认的 'model_name': 'deepseek-ai/DeepSeek-V3.1',
|
||
llm = ChatSiliconFlow(model="deepseek-ai/DeepSeek-R1-0528-Qwen3-8B")
|
||
for chunk in llm.stream("一句话介绍一下你自己,50字以内"):
|
||
print(chunk.text, end="", flush=True)
|
||
|
||
|
||
|
||
# response = llm.invoke("一句话介绍一下你自己,50字以内")
|
||
# print(response) |