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
相关推荐
码途行者7 小时前
每天10分钟学Go:第17课 接口interface-只规定“能做什么“,不管它是什么
开发语言·后端·golang
头发还在的女程序员7 小时前
Java充电桩平台源码解析:枪口状态、上报时间与页面刷新怎样协同
java·开发语言·充电桩系统·充电桩管理·充电系统·充电小程序
timeDifference₇9 小时前
Python Vibe Coding实操实验报告
开发语言·jvm·python
geovindu10 小时前
python:DecisionTree
开发语言·后端·python·算法
怒放的生命199111 小时前
代码知识库 RAG 问答系统 —— 从 0 到 1 实现教程
python·状态模式·fastapi·全栈开发·ai agent应用开发
geovindu11 小时前
python: Decision Tree Regressor
开发语言·后端·python·算法·决策树
fengkai454512 小时前
Python运维
运维·python·监控·psutil·ipy
Fancy.76112 小时前
:Python条件与循环语句学习总结
python
Wellijohn14 小时前
Python 容器选型实测:list.insert(0) 慢 925 倍,in 慢 6000 倍
python
新*14 小时前
标题全变成一级?靠编号规律找回章节边界
python·正则表达式·pdf解析·文本处理