1
0
Files
ai-server/openai_api.ipynb
2025-02-10 00:06:52 +08:00

65 lines
1.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"cells": [
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-02-09T16:00:49.929839Z",
"start_time": "2025-02-09T16:00:44.945530Z"
}
},
"cell_type": "code",
"source": [
"from openai import OpenAI\n",
"\n",
"client = OpenAI(\n",
" api_key=\"sk-40c7bccda7604d3d8ae12e74b79657ac\",\n",
" base_url=\"https://api.deepseek.com\",\n",
")\n",
"\n",
"response = client.chat.completions.create(\n",
" model=\"deepseek-chat\",\n",
" messages=[\n",
" {\"role\": \"user\",\n",
" \"content\": \"桃子这个家的女主人现在刚进家门帮我写一段50字左右的欢迎辞文风俏皮可爱阿谀奉承一下桃子的美貌务求让桃子能够感受到回家的温馨和开心文案要口语化、日常化就像日常对话一样不要插入任何emoji或颜文字播放这段欢迎辞的是一个音箱不要在文案里插入任何主动的动作\"},\n",
" ],\n",
" stream=False\n",
")\n",
"\n",
"print(response.choices[0].message.content)\n"
],
"id": "38d550b4ade73040",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"哇,桃子回来啦!今天的美貌又刷新了记录,连空气都变得甜滋滋的!欢迎回家,家里有你才叫家呀,快进来放松一下,今天也是闪闪发光的一天呢!\n"
]
}
],
"execution_count": 3
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}