您尝试访问openai.File,但这在openai>=1.0.0中已不再支持

我在ChatGPT中进行微调,目的是调整模型,使其根据特定主题(概念)定义一组子主题(或相关概念)。

这是我的训练数据集:

{"prompt":"Wellbeing of Child->","completion":" Immunization, Equal nurturing of boys and girls, Parents Mental health, Shaking baby, Children with disabilities, Dental care (only gum care), Importance of height and weight measurement, Feeding during sickness, Playing with rattle, Make mealtimes fun, Avoid physical maltreatment, Reducing screen time, Childrens common diseases, Nurturing care for children\n"}{"prompt":"Learning and Development->","completion":" Reducing screen time, Ways of learnings, Family values, Show name talk, Importance of height and weight measurement, Toilet training, Sorting and matching, Drowning, Learning through play\n"}{"prompt":"Hygiene and Safety->","completion":" Hygiene, Safety, Drowning, Handwashing, Avoid physical maltreatment\n"}{"prompt":"Breastfeeding->","completion":" Importance of Breastfeeding, Method of breastfeeding, Demerits of Infant formula milk, Maternal Nutrition, Sore Nipples, Feeding during sickness, Complementary feeding, Healthy feeding, Interactions with baby during breastfeeding\n"}

这是我正在运行的脚本:

import openaiimport jsonimport osapi_key =" "openai.api_key = api_key##Cheking training data!openai tools fine_tunes.prepare_data -f training_data_prepared.jsonl -qresponse = openai.File.create(    file=open("training_data_prepared.jsonl","rb"),    purpose = "fine-tune")print(response)

在响应函数中,我收到了以下错误:

APIRemovedInV1: You tried to access openai.File, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface. Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742

我知道这是openai库版本错误,但我一直在寻找解决方案,但没有任何效果。


回答:

更改如下:

response = openai.File.create(    file=open("training_data_prepared.jsonl","rb"),    purpose = "fine-tune")

改为

response = client.files.create(        file=open("training_data_prepared.jsonl","rb"),        purpose = "fine-tune")

详细的迁移指南在这里:

https://github.com/openai/openai-python/discussions/742

变更一览:

enter image description here

或者,您可以使用旧版本(尽管不推荐)

pip install openai==0.28

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注