当前位置: 首页> 科技> 能源 > OpenAI, Python, Delete File

OpenAI, Python, Delete File

时间:2025/7/11 1:12:28来源:https://blog.csdn.net/suiusoar/article/details/140923065 浏览次数:0次

题意:OpenAI, Python, 删除文件

问题背景:

In order to test some OpenAI file functionalities (Answer, Search etc.), I created several files using python through the OpenAI API.

为了测试一些OpenAI的文件功能(如回答、搜索等),我通过OpenAI API使用Python创建了几个文件。

As per OpenAI [files documentation][1] I am now trying to delete the file(s) I created as follows:

根据OpenAI的[文件文档][1],我现在正尝试删除我之前创建的文件,具体做法如下:

openai.File("file-CQ0tfZ4p3Hihlbwi1tQYmZV2").delete()

the error I get is as follows:        我得到了以下的错误:

TypeError: delete() missing 1 required positional argument: 'sid'

I know the file exists as I am able to print it's properties. My coding ability is fairly basic... how can I delete some...or all the files.

我知道文件存在,因为我能够打印出它的属性。我的编程能力相当基础...我该如何删除一些...或全部文件。

The entire code snippet is as follows:        完整的代码片段如下:

import openai#set environment variable and print
os.environ['OPENAI_API_KEY'] = '*************************'
os.environ.get('OPENAI_API_KEY')openai.File("file-CQ0tfZ4p3Hihlbwi1tQYmZV2").delete()

问题解决:

There is a bug in the OpenAI documentation. 

OpenAI 文档中存在bug 

You have to delete as follow :        需要删除以下内容

openai.File.delete("file-CQ0tfZ4p3Hihlbwi1tQYmZV2")

instead of        用以下内容替换

openai.File("file-CQ0tfZ4p3Hihlbwi1tQYmZV2").delete()

关键字:OpenAI, Python, Delete File

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: