# 调用内置函数
length = len("hello") # 返回 5
# 调用库函数
import math
result = math.sqrt(16) # 返回 4.0
# 调用自定义函数
def add(a, b):
return a + b
sum = add(3, 5) # 返回 8
POST /v1/chat/completions HTTP/1.1
Host: api.deepseek.com
Authorization: Bearer sk-xxx
Content-Type: application/json
{
"model": "deepseek-chat",
"messages": [
{"role": "user", "content": "你好"}
]
}
def open(file: str, mode: str = 'r') -> TextIO:
"""
打开文件并返回文件对象
Args:
file: 文件路径
mode: 打开模式 ('r', 'w', 'a')
Returns:
文件对象
Raises:
FileNotFoundError: 文件不存在
"""
POST /v1/chat/completions
Headers:
Authorization: Bearer {api_key}
Content-Type: application/json
Body:
{
"model": "deepseek-chat",
"messages": [...],
"temperature": 0.7
}
Response:
{
"choices": [{
"message": {"content": "..."}
}]
}
() 调用?