Python scrips to interact with the OpenAI API. This repo is mirrored at https://github.com/kikobar/openai-api
| output_images | ||
| .gitignore | ||
| __init__.py | ||
| cancel_model_response.py | ||
| CODE_OF_CONDUCT.md | ||
| config-sample.py | ||
| CONTRIBUTING.md | ||
| create_conversation.py | ||
| create_image.py | ||
| create_model_response.py | ||
| create_text_item.py | ||
| create_vector_store.py | ||
| create_vector_store_file.py | ||
| delete_conversation.py | ||
| delete_file.py | ||
| delete_item.py | ||
| delete_model_response.py | ||
| delete_vector_store.py | ||
| delete_vector_store_file.py | ||
| LICENSE.md | ||
| list_files.py | ||
| list_input_items.py | ||
| list_items.py | ||
| list_vector_store_files.py | ||
| list_vector_stores.py | ||
| modify_vector_store.py | ||
| README.md | ||
| retrieve_conversation.py | ||
| retrieve_file.py | ||
| retrieve_file_content.py | ||
| retrieve_item.py | ||
| retrieve_model_response.py | ||
| retrieve_vector_store.py | ||
| retrieve_vector_store_file.py | ||
| retrieve_vector_store_file_content.py | ||
| SECURITY.md | ||
| update_conversation.py | ||
| update_vector_store_file.py | ||
| upload_file.py | ||
Objective
These Python scripts allow to interact with the OpenAI API. You can manipulate the main abstractions of the OpenAI model:
- Conversations
- Responses
- Inputs
- Items
- Vector Stores
- Files
Requirements
- Python installed on the machine running this application.
- Credentials for accessing the OpenAI API - you will need to singup to the OpenAI portal. You will then be able to craete your credentials from within the portal.
How to run this application
-
Copy the file
config-sample.pytoconfig.py. -
Edit
config.pywith your credentials and defaults. -
Each script has a number of mandatory parameters in strict order:
Script Parameter 1 Parameter 2 Parameter 3 Purpose cancel_model_response.pyresponse_idCancel a Response running in the background create_conversation.pyCreate a new Conversation create_image.pymodel_idpromptCreate an image based on the prompt description create_model_response.pyconversation_idmodel_idinput_messageCreate a Response within a Conversation create_text_item.pyconversation_idinput_messageCreate a user input or instruction within a Conversation create_vector_store.pyCreate a Vector Store create_vector_store_file.pyvector_store_idfile_idCreate a File in a Vector Store delete_conversation.pyconversation_idDelete a Conversation delete_file.pyfile_idDelete a File delete_item.pyconversation_iditem_idDelete an Item (input or Response) from a Conversation delete_model_response.pyresponse_idDelete a Response delete_vector_store.pyvector_store_idDelete a Vector Store delete_vector_store_file.pyvector_store_idfile_idDelete a File from a Vector Store list_files.pyList all uploaded Files list_input_items.pyresponse_idList all input Items used to generate a Response list_items.pyconversation_idList all Items (inputs or Responses) in a Conversation list_vector_store_files.pyvector_store_idList all Files in a Vector Store list_vector_stores.pyList all Vector Stores modify_vector_store.pyvector_store_idmetadataUpdate a Vector Store metadata retrieve_conversation.pyconversation_idRetrieve a Conversation retrieve_file.pyfile_idRetrieve a File retrieve_file_content.pyfile_idRetrieve the content of File retrieve_item.pyconversation_iditem_idRetrieve an Item from a Conversation retrieve_model_response.pyresponse_idRetrieve a model Response retrieve_vector_store.pyvector_store_idRetrieve a Vector Store retrieve_vector_store_file.pyvector_store_idfile_idRetrieve a File from a Vector Store retrieve_vector_store_file_content.pyvector_store_idfile_idRetrieve the content of a File from a Vector Store update_conversation.pyconversation_idmetadataUpdate a Conversation metadata update_vector_store_file.pyvector_store_idfile_idattributesUpdate a File attributes upload_file.pyfilenamepath-to-fileUpload a File to the OpenAI platform -
To execute these scripts run
python3 <script.py> <parameter_1> ....