openai-api - 如何使用 chatgpt 读取和写入计算机上的文件夹

标签 openai-api chatgpt-api chatgpt-plugin

我知道chatgpt无法访问计算机上的文件系统,并且需要插件或API来执行此操作,并且我在他们的等待名单上。但我现在想实现它。例如,我可以将一个文件放在谷歌云上并创建一个共享链接并将其提供给 chatgpt 供阅读,但这并不实用。

例如,我可以使用 API 并像这样从计算机上运行它并且工作正常。

import openai 
import os 
# Initialize the OpenAI API with your key 
openai.api_key = '' 

# Specify the paths to the question and answer files
question_file_path = os.path.join('c:/Users/kehsa/', 'gpt-projects/chatgpt/', 'questions/', 'questions.txt')
answer_file_path = os.path.join('c:/Users/kehsa/', 'gpt-projects/chatgpt/', 'answers/', 'answers.txt')

# Read the question from the file with
with open(question_file_path, 'r') as question_file:
    question = question_file.read()

# Send the question to the GPT-3 model. Increase max_tokens for more complex question / responses
response = openai.Completion.create(engine="text-davinci-003", prompt=question, max_tokens=60)

# Write the model's response to the answer file with error handling
if os.path.exists(answer_file_path):
    with open(answer_file_path, 'w') as answer_file:
        answer_file.write(response.choices[0].text.strip())
else:
    with open(answer_file_path, 'x') as answer_file:
        answer_file.write(response.choices[0].text.strip())

但是我想在chatgpt中输入“python/filepath/filename.py”或“load/filepath/filename”,就像一个codelet演示一样,我看到它加载了一个panda df文件并通过简单地对其运行数据可视化键入:

“加载文件.csv”

“在 file.csv 上运行数据可视化”

最佳答案

ChatGPT 没有能力做到这一点。 只有两种方法可以满足您的要求。

  1. 开发一个 ChatGPT 插件,该插件将在公共(public)网络服务器上运行并以某种方式访问​​您的计算机以执行文件操作。
  2. 使用 OpenAI API 并在您的计算机上创建一个应用程序,该应用程序可以使用 OpenAI API 来帮助确定和运行工具来帮助完成所需的工作。可以执行此操作的库的示例是 LangChain设置使用 File System Tools支持文件系统操作的代理。

关于openai-api - 如何使用 chatgpt 读取和写入计算机上的文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76222270/

相关文章:

openai-api - 如何让ChatGPT返回用自己的数据训练时返回的信息来源

python - OpenAI 身份验证错误 : No API key provided for open ai api

openai-api - 是否有本地版本的 chatgpt 不会将任何数据传播到欧盟之外以遵守 GDPR?

python - 使用 Python 和 Kivy 库创建具有 Openai 人工智能的虚拟助手

openai-api - 如何在云端微调和部署ChatGPT?

python - 使用Vicuna + langchain + llama_index 创建自托管LLM模型

azure - 授予用户对 Azure OpenAI-Studio 和/或 GPT-3 Playground 的访问权限

reinforcement-learning - 为什么 Stable-Baselines3 evaluate_policy() 函数永远不会完成/完成?

openai-api - 天蓝色ai工作室错误: Missing header 'chatgpt_url' in request