Compare commits
No commits in common. "656bfa79dff9c86cd6f11f50af2a5d40c78ee645" and "19b13ecbffe355f8c094e6b2342f407212a51961" have entirely different histories.
656bfa79df
...
19b13ecbff
51
README.md
51
README.md
|
@ -7,8 +7,6 @@ You can manipulate the main abstractions of the OpenAI model:
|
||||||
* Responses
|
* Responses
|
||||||
* Inputs
|
* Inputs
|
||||||
* Items
|
* Items
|
||||||
* Vector Stores
|
|
||||||
* Files
|
|
||||||
|
|
||||||
**Requirements**
|
**Requirements**
|
||||||
|
|
||||||
|
@ -18,39 +16,22 @@ You can manipulate the main abstractions of the OpenAI model:
|
||||||
**How to run this application**
|
**How to run this application**
|
||||||
|
|
||||||
* Copy the file `config-sample.py` to `config.py`.
|
* Copy the file `config-sample.py` to `config.py`.
|
||||||
|
|
||||||
* Edit `config.py` with your credentials and defaults.
|
* Edit `config.py` with your credentials and defaults.
|
||||||
|
|
||||||
* Each script has a number of mandatory parameters in strict order:
|
* Each script has a number of mandatory parameters in strict order:
|
||||||
|
| Script | Parameter 1 | Parameter 2 | Parameter 3 | Purpose |
|
||||||
| Script | Parameter 1 | Parameter 2 | Parameter 3 | Purpose |
|
| ---------------------------- | ----------------- | --------------- | --------------- | -------------------------------------------------------- |
|
||||||
| --------------------------------------- | ----------------- | --------------- | --------------- | -------------------------------------------------------- |
|
| `cancel_model_response.py` | `response_id` | | | Cancel a Response running in the background |
|
||||||
| `cancel_model_response.py` | `response_id` | | | Cancel a Response running in the background |
|
| `create_conversation.py` | | | | Create a new Conversation |
|
||||||
| `create_conversation.py` | | | | Create a new Conversation |
|
| `create_model_response.py` | `conversation_id` | `model_id` | `input_message` | Create a Response within a Conversation |
|
||||||
| `create_model_response.py` | `conversation_id` | `model_id` | `input_message` | Create a Response within a Conversation |
|
| `create_text_item.py` | `conversation_id` | `input_message` | | Create a user input or instruction within a Conversation |
|
||||||
| `create_text_item.py` | `conversation_id` | `input_message` | | Create a user input or instruction within a Conversation |
|
| `delete_conversation.py` | `conversation_id` | | | Delete a Conversation |
|
||||||
| `create_vector_store.py` | | | | Create a Vector Store |
|
| `delete_item.py` | `conversation_id` | `item_id` | | Delete an Item (input or Response) from a Conversation |
|
||||||
| `create_vector_store_file.py` | `vector_store_id` | `file_id` | | Create a File in a Vector Store |
|
| `delete_model_response.py` | `response_id` | | | Delete a Response |
|
||||||
| `delete_conversation.py` | `conversation_id` | | | Delete a Conversation |
|
| `list_input_items.py` | `response_id` | | | List all input Items used to generate a Response |
|
||||||
| `delete_file.py` | `file_id` | | | Delete a File |
|
| `list_items.py` | `conversation_id` | | | List all Items (inputs or Responses) in a Conversation |
|
||||||
| `delete_item.py` | `conversation_id` | `item_id` | | Delete an Item (input or Response) from a Conversation |
|
| `retrieve_conversation.py` | `conversation_id` | | | Retrieve a Conversation |
|
||||||
| `delete_model_response.py` | `response_id` | | | Delete a Response |
|
| `retrieve_item.py` | `conversation_id` | `item_id` | | Retrieve an Item from a Conversation |
|
||||||
| `delete_vector_store.py` | `vector_store_id` | | | Delete a Vector Store |
|
| `retrieve_model_response.py` | `response_id` | | | Retrieve a model Response |
|
||||||
| `delete_vector_store_file.py` | `vector_store_id` | `file_id` | | Delete a File from a Vector Store |
|
| `update_conversation.py` | `conversation_id` | `metadata` | | Update a Conversation metadata |
|
||||||
| `list_files.py` | | | | List all uploaded Files |
|
|
||||||
| `list_input_items.py` | `response_id` | | | List all input Items used to generate a Response |
|
|
||||||
| `list_items.py` | `conversation_id` | | | List all Items (inputs or Responses) in a Conversation |
|
|
||||||
| `list_vector_store_files.py` | `vector_store_id` | | | List all Files in a Vector Store |
|
|
||||||
| `list_vector_stores.py` | | | | List all Vector Stores |
|
|
||||||
| `retrieve_conversation.py` | `conversation_id` | | | Retrieve a Conversation |
|
|
||||||
| `retrieve_file.py` | `file_id` | | | Retrieve a File |
|
|
||||||
| `retrieve_file_content.py` | `file_id` | | | Retrieve the content of File |
|
|
||||||
| `retrieve_item.py` | `conversation_id` | `item_id` | | Retrieve an Item from a Conversation |
|
|
||||||
| `retrieve_model_response.py` | `response_id` | | | Retrieve a model Response |
|
|
||||||
| `retrieve_vector_store.py` | `vector_store_id` | | | Retrieve a Vector Store |
|
|
||||||
| `retrieve_vector_store_file.py` | `vector_store_id` | `file_id` | | Retrieve a File from a Vector Store |
|
|
||||||
| `retrieve_vector_store_file_content.py` | `vector_store_id` | `file_id` | | Retrieve the content of a File from a Vector Store |
|
|
||||||
| `update_conversation.py` | `conversation_id` | `metadata` | | Update a Conversation metadata |
|
|
||||||
| `upload_file.py` | `filename` | `path-to-file` | | Upload a File to the OpenAI platform |
|
|
||||||
|
|
||||||
* To execute these scripts run `python3 <script.py> <parameter_1> ...`.
|
* To execute these scripts run `python3 <script.py> <parameter_1> ...`.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
base_url = "https://api.openai.com/v1/"
|
base_url = "https://api.openai.com/v1/"
|
||||||
secret_key = "YOUR-OPENAI-SECRET-KEY-HERE"
|
secret_key = "YOUR-OPENAI-SECRET-KEY-HERE"
|
||||||
vector_store = "YOUR-VECTOR-STORE-ID-HERE"
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ def create_model_response(conversation,model,message):
|
||||||
"model": model,
|
"model": model,
|
||||||
"tools": [
|
"tools": [
|
||||||
{"type": "web_search"},
|
{"type": "web_search"},
|
||||||
{"type": "file_search", "vector_store_ids" :[vector_store]}
|
|
||||||
],
|
],
|
||||||
"input": message,
|
"input": message,
|
||||||
"conversation": conversation
|
"conversation": conversation
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
|
|
||||||
url = base_url+"vector_stores"
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("POST", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def create_vector_store_file(vector_store_id,file_id):
|
|
||||||
url = base_url+"vector_stores/"+vector_store_id+"/files"
|
|
||||||
|
|
||||||
payload = json.dumps({
|
|
||||||
"file_id": file_id
|
|
||||||
})
|
|
||||||
headers = {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("POST", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
create_vector_store_file(str(sys.argv[1]),str(sys.argv[2]))
|
|
|
@ -1,19 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def delete_file(file_id):
|
|
||||||
url = base_url+"files/"+file_id
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("DELETE", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
delete_file(str(sys.argv[1]))
|
|
|
@ -1,19 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def delete_vector_store(vector_store):
|
|
||||||
url = base_url+"vector_stores/"+vector_store
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("DELETE", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
delete_vector_store(str(sys.argv[1]))
|
|
|
@ -1,19 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def delete_vector_store_file(vector_store,file_id):
|
|
||||||
url = base_url+"vector_stores/"+vector_store+"/files/"+file_id
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("DELETE", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
delete_vector_store_file(str(sys.argv[1]),str(sys.argv[2]))
|
|
|
@ -1,14 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
|
|
||||||
url = base_url+"files"
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("GET", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def list_vector_store_files(vector_store):
|
|
||||||
url = base_url+"vector_stores/"+vector_store+"/files"
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("GET", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
list_vector_store_files(str(sys.argv[1]))
|
|
|
@ -1,14 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
|
|
||||||
url = base_url+"vector_stores"
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("GET", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def retrieve_file(file_id):
|
|
||||||
url = base_url+"files/"+file_id
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("GET", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
retrieve_file(str(sys.argv[1]))
|
|
|
@ -1,19 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def retrieve_file_content(file_id):
|
|
||||||
url = base_url+"files/"+file_id+"/content"
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("GET", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
retrieve_file_content(str(sys.argv[1]))
|
|
|
@ -1,19 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def retrieve_vector_store(vector_store):
|
|
||||||
url = base_url+"vector_stores/"+vector_store
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("GET", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
retrieve_vector_store(str(sys.argv[1]))
|
|
|
@ -1,19 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def retrieve_vector_store_file(vector_store,file_id):
|
|
||||||
url = base_url+"vector_stores/"+vector_store+"/files/"+file_id
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("GET", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
retrieve_vector_store_file(str(sys.argv[1]),str(sys.argv[2]))
|
|
|
@ -1,19 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def retrieve_vector_store_file_content(vector_store,file_id):
|
|
||||||
url = base_url+"vector_stores/"+vector_store+"/files/"+file_id+"/content"
|
|
||||||
|
|
||||||
payload = {}
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("GET", url, headers=headers, data=payload)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
retrieve_vector_store_file_content(str(sys.argv[1]),str(sys.argv[2]))
|
|
|
@ -1,22 +0,0 @@
|
||||||
from config import *
|
|
||||||
import requests
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def upload_file(filename, path):
|
|
||||||
url = base_url+"files"
|
|
||||||
|
|
||||||
payload = {'purpose': 'user_data'}
|
|
||||||
files=[
|
|
||||||
('file',(filename,open(path,'rb'),'application/pdf'))
|
|
||||||
]
|
|
||||||
headers = {
|
|
||||||
'Authorization': 'Bearer '+secret_key,
|
|
||||||
}
|
|
||||||
|
|
||||||
response = requests.request("POST", url, headers=headers, data=payload, files=files)
|
|
||||||
|
|
||||||
print(response.text)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
upload_file(str(sys.argv[1]),str(sys.argv[2]))
|
|
Loading…
Reference in a new issue