以openai的gpt3 5为例的大模型流式输出实现(原始、Sanic、Flask)- 附免费的key
以openai的gpt3.5为例的大模型流式输出实现(原始、Sanic、Flask)- 附免费的apikey水龙头
type: Post
status: Draft
date: 2024/10/09
📝 原始
import openai
openai.api_key = 'sk-xxx'
openai.base_url = 'xxx'
resp = openai.chat.completions.create(
model = 'gpt-3.5-turbo',
messages = [{
"role":'user', "content": '详细介绍一下内马尔'}],
stream = True
)
for chunk in resp:
# if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end='')
🤗 Sanic
import json
from sanic import Sanic, response
import openai
app = Sanic(__name__)
openai.api_key = "sk-xxx"
openai.base_url = "xxx"
async def process_large_
原文地址:https://blog.csdn.net/CSDN_Lrcx/article/details/142798815
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!