gpt4 book ai didi

python - 没有名为 'openai_secret_manager' 的模块

转载 作者:行者123 更新时间:2023-12-02 05:46:20 24 4
gpt4 key购买 nike

我向 ChatGPT 询问我的 CSV 数据,ChatGPT 回答:

“以下示例展示了如何使用 pandas 读取 CSV 文件,然后使用该数据通过 OpenAI 来训练或微调 GPT-3 API:“

import pandas as pd
import openai_secret_manager

# Read the CSV file
df = pd.read_csv("example.csv")

# Get the OpenAI API key
secrets = openai_secret_manager.get_secrets("openai")
openai_api_key = secrets["api_key"]

# Use the data from the CSV file to train or fine-tune GPT-3
# (Assuming you have the OpenAI API key and the OpenAI Python library installed)
import openai
openai.api_key = openai_api_key
response = openai.Completion.create(
engine="text-davinci-002",
prompt=(f"train on data from example.csv{df}"),
max_tokens=2048,
n = 1,
stop=None,
temperature=0.5,
)
print(response["choices"][0]["text"])

但是,我收到了这个错误:

ModuleNotFoundError:没有名为“openai_secret_manager”的模块

最佳答案

无需使用openai_secret_manager。我遇到了同样的问题并删除了它,您需要从您在 OpenAI 上的帐户生成 API 并将其直接放置到代码中。

import pandas as pd
import openai_secret_manager

# Read the CSV file
df = pd.read_csv("example.csv")

# Use the data from the CSV file to train or fine-tune GPT-3
# (Assuming you have the OpenAI API key and the OpenAI Python library installed)
import openai
openai.api_key = openai_api_key
response = openai.Completion.create(
engine="text-davinci-002",
prompt=(f"train on data from example.csv{df}"),
max_tokens=2048,
n = 1,
stop=None,
temperature=0.5,
)
print(response["choices"][0]["text"])

enter image description here

复制并粘贴 API 并在此处替换 openai_api_key

openai.api_key = "PLACE_YOUR_API_IN_HERE"

关于python - 没有名为 'openai_secret_manager' 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75112672/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com