|
@@ -58,10 +58,10 @@
|
|
|
|
|
|
|
|
# total1 = bytes/1024/1024/1024
|
|
# total1 = bytes/1024/1024/1024
|
|
|
|
|
|
|
|
-# print("assistants:")
|
|
|
|
|
-# print(len(list.data))
|
|
|
|
|
-# print(str(total1) + "G")
|
|
|
|
|
-# print('')
|
|
|
|
|
|
|
+# #print("assistants:")
|
|
|
|
|
+# #print(len(list.data))
|
|
|
|
|
+# #print(str(total1) + "G")
|
|
|
|
|
+# #print('')
|
|
|
|
|
|
|
|
# list = openai.files.list(
|
|
# list = openai.files.list(
|
|
|
# purpose="assistants",
|
|
# purpose="assistants",
|
|
@@ -75,10 +75,10 @@
|
|
|
|
|
|
|
|
# total2 = bytes/1024/1024/1024
|
|
# total2 = bytes/1024/1024/1024
|
|
|
|
|
|
|
|
-# print("assistants:")
|
|
|
|
|
-# print(len(list.data))
|
|
|
|
|
-# print(str(total2) + "G")
|
|
|
|
|
-# print('')
|
|
|
|
|
|
|
+# #print("assistants:")
|
|
|
|
|
+# #print(len(list.data))
|
|
|
|
|
+# #print(str(total2) + "G")
|
|
|
|
|
+# #print('')
|
|
|
|
|
|
|
|
# list = openai.files.list(
|
|
# list = openai.files.list(
|
|
|
# purpose="assistants",
|
|
# purpose="assistants",
|
|
@@ -92,10 +92,10 @@
|
|
|
|
|
|
|
|
# total3 = bytes/1024/1024/1024
|
|
# total3 = bytes/1024/1024/1024
|
|
|
|
|
|
|
|
-# print("assistants:")
|
|
|
|
|
-# print(len(list.data))
|
|
|
|
|
-# print(str(total3) + "G")
|
|
|
|
|
-# print('')
|
|
|
|
|
|
|
+# #print("assistants:")
|
|
|
|
|
+# #print(len(list.data))
|
|
|
|
|
+# #print(str(total3) + "G")
|
|
|
|
|
+# #print('')
|
|
|
|
|
|
|
|
# list = openai.files.list(
|
|
# list = openai.files.list(
|
|
|
# purpose="assistants",
|
|
# purpose="assistants",
|
|
@@ -109,10 +109,10 @@
|
|
|
|
|
|
|
|
# total4 = bytes/1024/1024/1024
|
|
# total4 = bytes/1024/1024/1024
|
|
|
|
|
|
|
|
-# print("assistants:")
|
|
|
|
|
-# print(len(list.data))
|
|
|
|
|
-# print(str(total4) + "G")
|
|
|
|
|
-# print('')
|
|
|
|
|
|
|
+# #print("assistants:")
|
|
|
|
|
+# #print(len(list.data))
|
|
|
|
|
+# #print(str(total4) + "G")
|
|
|
|
|
+# #print('')
|
|
|
|
|
|
|
|
# list = openai.files.list(
|
|
# list = openai.files.list(
|
|
|
# purpose="assistants",
|
|
# purpose="assistants",
|
|
@@ -126,17 +126,17 @@
|
|
|
|
|
|
|
|
# total5 = bytes/1024/1024/1024
|
|
# total5 = bytes/1024/1024/1024
|
|
|
|
|
|
|
|
-# print("assistants:")
|
|
|
|
|
-# print(len(list.data))
|
|
|
|
|
-# print(str(total5) + "G")
|
|
|
|
|
-# print('')
|
|
|
|
|
|
|
+# #print("assistants:")
|
|
|
|
|
+# #print(len(list.data))
|
|
|
|
|
+# #print(str(total5) + "G")
|
|
|
|
|
+# #print('')
|
|
|
|
|
|
|
|
-# # print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
-# print(len(list_new_pdf))
|
|
|
|
|
-# print(total1 + total2 + total3 + total4 + total5)
|
|
|
|
|
|
|
+# # #print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
+# #print(len(list_new_pdf))
|
|
|
|
|
+# #print(total1 + total2 + total3 + total4 + total5)
|
|
|
|
|
|
|
|
# # for item in list_new_pdf:
|
|
# # for item in list_new_pdf:
|
|
|
-# # print(item)
|
|
|
|
|
|
|
+# # #print(item)
|
|
|
|
|
|
|
|
# list_new_pdf_new = []
|
|
# list_new_pdf_new = []
|
|
|
# bytes = 0
|
|
# bytes = 0
|
|
@@ -145,9 +145,9 @@
|
|
|
# bytes = bytes + item.bytes
|
|
# bytes = bytes + item.bytes
|
|
|
# list_new_pdf_new.append(item)
|
|
# list_new_pdf_new.append(item)
|
|
|
|
|
|
|
|
-# print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
-# print(len(list_new_pdf_new))
|
|
|
|
|
-# # print(list_new_pdf_new[3])
|
|
|
|
|
|
|
+# #print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
+# #print(len(list_new_pdf_new))
|
|
|
|
|
+# # #print(list_new_pdf_new[3])
|
|
|
# pdf = []
|
|
# pdf = []
|
|
|
|
|
|
|
|
# for item in list_new_pdf_new:
|
|
# for item in list_new_pdf_new:
|
|
@@ -156,11 +156,11 @@
|
|
|
|
|
|
|
|
# bytes = 0
|
|
# bytes = 0
|
|
|
# for item in pdf:
|
|
# for item in pdf:
|
|
|
-# print(item)
|
|
|
|
|
|
|
+# #print(item)
|
|
|
# bytes = bytes + item.bytes
|
|
# bytes = bytes + item.bytes
|
|
|
|
|
|
|
|
-# print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
-# print(len(pdf))
|
|
|
|
|
|
|
+# #print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
+# #print(len(pdf))
|
|
|
|
|
|
|
|
|
|
|
|
|
# for item in pdf:
|
|
# for item in pdf:
|
|
@@ -175,8 +175,8 @@
|
|
|
# bytes = bytes + item.bytes
|
|
# bytes = bytes + item.bytes
|
|
|
# list_new_pdf_new.append(item)
|
|
# list_new_pdf_new.append(item)
|
|
|
|
|
|
|
|
-# print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
-# print(len(list_new_pdf_new))
|
|
|
|
|
|
|
+# #print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
+# #print(len(list_new_pdf_new))
|
|
|
|
|
|
|
|
# list_new_pdf_new = []
|
|
# list_new_pdf_new = []
|
|
|
# bytes = 0
|
|
# bytes = 0
|
|
@@ -185,8 +185,8 @@
|
|
|
# bytes = bytes + item.bytes
|
|
# bytes = bytes + item.bytes
|
|
|
# list_new_pdf_new.append(item)
|
|
# list_new_pdf_new.append(item)
|
|
|
|
|
|
|
|
-# print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
-# print(len(list_new_pdf_new))
|
|
|
|
|
|
|
+# #print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
+# #print(len(list_new_pdf_new))
|
|
|
|
|
|
|
|
# list_new_pdf = []
|
|
# list_new_pdf = []
|
|
|
# bytes = 0
|
|
# bytes = 0
|
|
@@ -195,22 +195,22 @@
|
|
|
# bytes = bytes + item.bytes
|
|
# bytes = bytes + item.bytes
|
|
|
# list_new_pdf.append(item)
|
|
# list_new_pdf.append(item)
|
|
|
|
|
|
|
|
-# print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
-# print(len(list_new_pdf))
|
|
|
|
|
|
|
+# #print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
+# #print(len(list_new_pdf))
|
|
|
|
|
|
|
|
# list = []
|
|
# list = []
|
|
|
# bytes = 0
|
|
# bytes = 0
|
|
|
# for i in range(16):
|
|
# for i in range(16):
|
|
|
# bytes = bytes + list_new[i].bytes
|
|
# bytes = bytes + list_new[i].bytes
|
|
|
-# print(list_new[i])
|
|
|
|
|
-# print('')
|
|
|
|
|
|
|
+# #print(list_new[i])
|
|
|
|
|
+# #print('')
|
|
|
# list.append(list_new[i])
|
|
# list.append(list_new[i])
|
|
|
|
|
|
|
|
-# print(list)
|
|
|
|
|
|
|
+# #print(list)
|
|
|
|
|
|
|
|
# for item in list_new_pdf:
|
|
# for item in list_new_pdf:
|
|
|
# if item.id == "file-1Mbqss6qX6GPnTKM6izCx1":
|
|
# if item.id == "file-1Mbqss6qX6GPnTKM6izCx1":
|
|
|
-# print(item)
|
|
|
|
|
|
|
+# #print(item)
|
|
|
|
|
|
|
|
# deleteList = ["file-9uYPz7MWTpjgsUhond2pdFVc","file-U7oU81MT34NTeHaZu6dv2yhq","file-nUyGEdScnyLCuRZ3a2vLCY6B","file-Uy8H9ePoGspsXyTwWUwwhAlK"]
|
|
# deleteList = ["file-9uYPz7MWTpjgsUhond2pdFVc","file-U7oU81MT34NTeHaZu6dv2yhq","file-nUyGEdScnyLCuRZ3a2vLCY6B","file-Uy8H9ePoGspsXyTwWUwwhAlK"]
|
|
|
|
|
|
|
@@ -222,15 +222,15 @@
|
|
|
# purpose="assistants_output",
|
|
# purpose="assistants_output",
|
|
|
# extra_query={"order":"desc"}
|
|
# extra_query={"order":"desc"}
|
|
|
# )
|
|
# )
|
|
|
-# # print(list)
|
|
|
|
|
|
|
+# # #print(list)
|
|
|
# bytes = 0
|
|
# bytes = 0
|
|
|
# for item in list.data:
|
|
# for item in list.data:
|
|
|
# if item.bytes != None:
|
|
# if item.bytes != None:
|
|
|
# bytes = bytes + item.bytes
|
|
# bytes = bytes + item.bytes
|
|
|
-# print("assistants_output:")
|
|
|
|
|
-# print(len(list.data))
|
|
|
|
|
-# print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
-# print('')
|
|
|
|
|
|
|
+# #print("assistants_output:")
|
|
|
|
|
+# #print(len(list.data))
|
|
|
|
|
+# #print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
+# #print('')
|
|
|
|
|
|
|
|
# list = openai.files.list(
|
|
# list = openai.files.list(
|
|
|
# purpose="batch",
|
|
# purpose="batch",
|
|
@@ -239,18 +239,18 @@
|
|
|
# bytes = 0
|
|
# bytes = 0
|
|
|
# for item in list.data:
|
|
# for item in list.data:
|
|
|
# bytes = bytes + item.bytes
|
|
# bytes = bytes + item.bytes
|
|
|
-# print("batch:")
|
|
|
|
|
-# print(len(list.data))
|
|
|
|
|
-# print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
-# print('')
|
|
|
|
|
|
|
+# #print("batch:")
|
|
|
|
|
+# #print(len(list.data))
|
|
|
|
|
+# #print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
+# #print('')
|
|
|
|
|
|
|
|
# list = openai.files.list(
|
|
# list = openai.files.list(
|
|
|
# purpose="batch_output",
|
|
# purpose="batch_output",
|
|
|
# extra_query={"order":"desc"}
|
|
# extra_query={"order":"desc"}
|
|
|
# )
|
|
# )
|
|
|
-# print("batch_output:")
|
|
|
|
|
-# print(len(list.data))
|
|
|
|
|
-# print('')
|
|
|
|
|
|
|
+# #print("batch_output:")
|
|
|
|
|
+# #print(len(list.data))
|
|
|
|
|
+# #print('')
|
|
|
|
|
|
|
|
# list = openai.files.list(
|
|
# list = openai.files.list(
|
|
|
# purpose="fine-tune",
|
|
# purpose="fine-tune",
|
|
@@ -259,18 +259,18 @@
|
|
|
# bytes = 0
|
|
# bytes = 0
|
|
|
# for item in list.data:
|
|
# for item in list.data:
|
|
|
# bytes = bytes + item.bytes
|
|
# bytes = bytes + item.bytes
|
|
|
-# print("fine-tune:")
|
|
|
|
|
-# print(len(list.data))
|
|
|
|
|
-# print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
-# print('')
|
|
|
|
|
|
|
+# #print("fine-tune:")
|
|
|
|
|
+# #print(len(list.data))
|
|
|
|
|
+# #print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
+# #print('')
|
|
|
|
|
|
|
|
# list = openai.files.list(
|
|
# list = openai.files.list(
|
|
|
# purpose="fine-tune-results",
|
|
# purpose="fine-tune-results",
|
|
|
# extra_query={"order":"desc"}
|
|
# extra_query={"order":"desc"}
|
|
|
# )
|
|
# )
|
|
|
-# print("fine-tune-results:")
|
|
|
|
|
-# print(len(list.data))
|
|
|
|
|
-# print('')
|
|
|
|
|
|
|
+# #print("fine-tune-results:")
|
|
|
|
|
+# #print(len(list.data))
|
|
|
|
|
+# #print('')
|
|
|
|
|
|
|
|
# list = openai.files.list(
|
|
# list = openai.files.list(
|
|
|
# purpose="vision",
|
|
# purpose="vision",
|
|
@@ -279,9 +279,9 @@
|
|
|
# bytes = 0
|
|
# bytes = 0
|
|
|
# for item in list.data:
|
|
# for item in list.data:
|
|
|
# bytes = bytes + item.bytes
|
|
# bytes = bytes + item.bytes
|
|
|
-# print("vision:")
|
|
|
|
|
-# print(len(list.data))
|
|
|
|
|
-# print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
|
|
+# #print("vision:")
|
|
|
|
|
+# #print(len(list.data))
|
|
|
|
|
+# #print(str(bytes/1024/1024/1024) + "G")
|
|
|
|
|
|
|
|
|
|
|
|
|
import logging
|
|
import logging
|
|
@@ -346,9 +346,9 @@ class EventHandler(openai.AssistantEventHandler):
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
file_path = os.path.join(os.path.dirname(__file__) + "/test.txt")
|
|
file_path = os.path.join(os.path.dirname(__file__) + "/test.txt")
|
|
|
- print(file_path)
|
|
|
|
|
|
|
+ #print(file_path)
|
|
|
file = client.files.create(file=Path(file_path), purpose="assistants")
|
|
file = client.files.create(file=Path(file_path), purpose="assistants")
|
|
|
- print(file)
|
|
|
|
|
|
|
+ #print(file)
|
|
|
|
|
|
|
|
assistant = client.beta.assistants.create(
|
|
assistant = client.beta.assistants.create(
|
|
|
name="Assistant Demo",
|
|
name="Assistant Demo",
|
|
@@ -360,10 +360,10 @@ if __name__ == "__main__":
|
|
|
tool_resources={"file_search": {"vector_stores": [{"file_ids": [file.id]}]}},
|
|
tool_resources={"file_search": {"vector_stores": [{"file_ids": [file.id]}]}},
|
|
|
)
|
|
)
|
|
|
# assistant = client.beta.assistants.retrieve(assistant_id="67614b38d5f1a0df9dddfba9")
|
|
# assistant = client.beta.assistants.retrieve(assistant_id="67614b38d5f1a0df9dddfba9")
|
|
|
- print("=====> : %s\n", assistant)
|
|
|
|
|
|
|
+ #print("=====> : %s\n", assistant)
|
|
|
|
|
|
|
|
thread = client.beta.threads.create()
|
|
thread = client.beta.threads.create()
|
|
|
- print("=====> : %s\n", thread)
|
|
|
|
|
|
|
+ #print("=====> : %s\n", thread)
|
|
|
|
|
|
|
|
message = client.beta.threads.messages.create(
|
|
message = client.beta.threads.messages.create(
|
|
|
thread_id=thread.id,
|
|
thread_id=thread.id,
|
|
@@ -373,7 +373,7 @@ if __name__ == "__main__":
|
|
|
# {"file_id": "67614b375e4b953d7f07c27a", "tools": [{"type": "file_search"}]}
|
|
# {"file_id": "67614b375e4b953d7f07c27a", "tools": [{"type": "file_search"}]}
|
|
|
# ]
|
|
# ]
|
|
|
)
|
|
)
|
|
|
- print("=====> : %s\n", message)
|
|
|
|
|
|
|
+ #print("=====> : %s\n", message)
|
|
|
|
|
|
|
|
event_handler = EventHandler()
|
|
event_handler = EventHandler()
|
|
|
|
|
|
|
@@ -389,7 +389,7 @@ if __name__ == "__main__":
|
|
|
and event.type == "thread.message.delta"
|
|
and event.type == "thread.message.delta"
|
|
|
and event.data.delta.content
|
|
and event.data.delta.content
|
|
|
):
|
|
):
|
|
|
- print(event.data.delta.content[0].text)
|
|
|
|
|
|
|
+ #print(event.data.delta.content[0].text)
|
|
|
|
|
|
|
|
"""
|
|
"""
|
|
|
with client.beta.threads.runs.stream(
|
|
with client.beta.threads.runs.stream(
|
|
@@ -398,36 +398,36 @@ if __name__ == "__main__":
|
|
|
event_handler=event_handler,
|
|
event_handler=event_handler,
|
|
|
extra_body={"stream_options": {"include_usage": True}},
|
|
extra_body={"stream_options": {"include_usage": True}},
|
|
|
) as stream:
|
|
) as stream:
|
|
|
- print(stream)
|
|
|
|
|
|
|
+ #print(stream)
|
|
|
stream.until_done()
|
|
stream.until_done()
|
|
|
"""
|
|
"""
|
|
|
# run = client.beta.threads.runs.create(
|
|
# run = client.beta.threads.runs.create(
|
|
|
# thread_id=thread.id,
|
|
# thread_id=thread.id,
|
|
|
# assistant_id=assistant.id,
|
|
# assistant_id=assistant.id,
|
|
|
# )
|
|
# )
|
|
|
-# print("=====> : %s\n", run)
|
|
|
|
|
|
|
+# #print("=====> : %s\n", run)
|
|
|
|
|
|
|
|
-# print("checking assistant status. \n")
|
|
|
|
|
|
|
+# #print("checking assistant status. \n")
|
|
|
# while True:
|
|
# while True:
|
|
|
# run = client.beta.threads.runs.retrieve(thread_id=thread.id, run_id=run.id)
|
|
# run = client.beta.threads.runs.retrieve(thread_id=thread.id, run_id=run.id)
|
|
|
# run_steps = client.beta.threads.runs.steps.list(run_id=run.id, thread_id=thread.id).data
|
|
# run_steps = client.beta.threads.runs.steps.list(run_id=run.id, thread_id=thread.id).data
|
|
|
# for run_step in run_steps:
|
|
# for run_step in run_steps:
|
|
|
-# print("=====> : %s\n", run_step)
|
|
|
|
|
|
|
+# #print("=====> : %s\n", run_step)
|
|
|
|
|
|
|
|
# if run.status == "completed":
|
|
# if run.status == "completed":
|
|
|
# messages = client.beta.threads.messages.list(thread_id=thread.id)
|
|
# messages = client.beta.threads.messages.list(thread_id=thread.id)
|
|
|
|
|
|
|
|
-# print("=====> messages:")
|
|
|
|
|
|
|
+# #print("=====> messages:")
|
|
|
# for message in messages:
|
|
# for message in messages:
|
|
|
# assert message.content[0].type == "text"
|
|
# assert message.content[0].type == "text"
|
|
|
-# print("%s", {"role": message.role, "message": message.content[0].text.value})
|
|
|
|
|
|
|
+# #print("%s", {"role": message.role, "message": message.content[0].text.value})
|
|
|
|
|
|
|
|
# # delete asst
|
|
# # delete asst
|
|
|
# client.beta.assistants.delete(assistant.id)
|
|
# client.beta.assistants.delete(assistant.id)
|
|
|
# break
|
|
# break
|
|
|
# elif run.status == "failed":
|
|
# elif run.status == "failed":
|
|
|
-# print("run failed %s\n", run.last_error)
|
|
|
|
|
|
|
+# #print("run failed %s\n", run.last_error)
|
|
|
# break
|
|
# break
|
|
|
# else:
|
|
# else:
|
|
|
-# print("in progress...\n")
|
|
|
|
|
|
|
+# #print("in progress...\n")
|
|
|
# time.sleep(5)
|
|
# time.sleep(5)
|