chatgpt 接口 和 jupyter版本安装

一 接口代码

有时间继续测试

python 复制代码
import openai
# 填入你的api_key
openai.api_key = ""


models = openai.Model.list()

# 定义API参数
params = {'role': "user", "content": ''}

# 定义循环
while True:
    # 获取用户输入
    user_input = input("请输入您的消息:")
    if user_input.lower() == "quit":
        break

    # 更新API参数
    params["content"] = user_input

    # 发送请求到API
    #response = requests.get(url, params=params)
    completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[
        params])
    print(completion.choices[0].message.content)

二 jupyter 推荐使用版本

1 安装 Jupyter 版本 1.0.0:

python 复制代码
pip install jupyter==1.0.0

2 安装 Jupyter Notebook 版本 6.4.5:

python 复制代码
pip install notebook==6.4.5

3 安装 scikit-learn 版本 1.1.3:

python 复制代码
pip install scikit-learn==1.1.3
相关推荐
jerrywus3 小时前
Claude Code vs. Codex:终极指南
chatgpt·agent·claude
会员源码网5 小时前
Python中生成器函数与普通函数的区别
python
Java水解5 小时前
Python开发从入门到精通:Web框架Django实战
后端·python
曲幽7 小时前
FastAPI + PostgreSQL 实战:给应用装上“缓存”和“日志”翅膀
redis·python·elasticsearch·postgresql·logging·fastapi·web·es·fastapi-cache
Lupino10 小时前
别再只聊 AI 写代码了:技术负责人要把“变更治理”提到第一优先级
python·docker·容器
Flittly11 小时前
【从零手写 ClaudeCode:learn-claude-code 项目实战笔记】(6)Context Compact (上下文压缩)
python·agent
曲幽1 天前
FastAPI + PostgreSQL 实战:从入门到不踩坑,一次讲透
python·sql·postgresql·fastapi·web·postgres·db·asyncpg
小兵张健1 天前
白嫖党的至暗时期
人工智能·chatgpt·aigc
用户8356290780511 天前
使用 C# 在 Excel 中创建数据透视表
后端·python
码路飞1 天前
FastMCP 实战:一个 .py 文件,给 Claude Code 装上 3 个超实用工具
python·ai编程·mcp