Mercurial > repos > bgruening > chatgpt_openai_api
annotate chatgpt.py @ 3:7770a4bd42e2 draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
author | bgruening |
---|---|
date | Wed, 11 Sep 2024 16:36:21 +0000 |
parents | dab494dce303 |
children |
rev | line source |
---|---|
3
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
1 import json |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
2 import os |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
3 import sys |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
4 |
3
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
5 from openai import AuthenticationError, OpenAI |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
6 |
3
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
7 context_files = json.loads(sys.argv[1]) |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
8 question = sys.argv[2] |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
9 model = sys.argv[3] |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
10 with open(sys.argv[4], "r") as f: |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
11 openai_api_key = f.read().strip() |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
12 if not openai_api_key: |
1
08c658e9aa9e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 13c168a7d6a2d5050c04253754fb86321ad57d54
bgruening
parents:
0
diff
changeset
|
13 print("OpenAI API key is not provided in user preferences!") |
08c658e9aa9e
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 13c168a7d6a2d5050c04253754fb86321ad57d54
bgruening
parents:
0
diff
changeset
|
14 sys.exit(1) |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
15 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
16 client = OpenAI(api_key=openai_api_key) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
17 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
18 file_search_file_streams = [] |
2
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
19 image_files = [] |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
20 |
3
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
21 for path, type in context_files: |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
22 if type == "image": |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
23 if os.path.getsize(path) > 20 * 1024 * 1024: |
2
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
24 print(f"File {path} exceeds the 20MB limit and will not be processed.") |
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
25 sys.exit(1) |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
26 file = client.files.create(file=open(path, "rb"), purpose="vision") |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
27 promt = {"type": "image_file", "image_file": {"file_id": file.id}} |
2
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
28 image_files.append(promt) |
3
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
29 else: |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
30 file_search_file_streams.append(open(path, "rb")) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
31 |
3
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
32 try: |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
33 assistant = client.beta.assistants.create( |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
34 instructions=( |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
35 "You will receive questions about files from file searches " |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
36 "and image files. For file search queries, identify and " |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
37 "retrieve the relevant files based on the question. " |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
38 "For image file queries, analyze the image content and " |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
39 "provide relevant information or insights based on the image data." |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
40 ), |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
41 model=model, |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
42 tools=[{"type": "file_search"}] if file_search_file_streams else [], |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
43 ) |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
44 except AuthenticationError as e: |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
45 print(f"Authentication error: {e.message}") |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
46 sys.exit(1) |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
47 except Exception as e: |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
48 print(f"An error occurred: {str(e)}") |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
49 sys.exit(1) |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
50 |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
51 if file_search_file_streams: |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
52 vector_store = client.beta.vector_stores.create() |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
53 file_batch = client.beta.vector_stores.file_batches.upload_and_poll( |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
54 vector_store_id=vector_store.id, files=file_search_file_streams |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
55 ) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
56 assistant = client.beta.assistants.update( |
2
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
57 assistant_id=assistant.id, |
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
58 tool_resources={"file_search": {"vector_store_ids": [vector_store.id]}}, |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
59 ) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
60 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
61 messages = [ |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
62 { |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
63 "role": "user", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
64 "content": [ |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
65 { |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
66 "type": "text", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
67 "text": question, |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
68 }, |
2
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
69 *image_files, |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
70 ], |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
71 } |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
72 ] |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
73 thread = client.beta.threads.create(messages=messages) |
2
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
74 run = client.beta.threads.runs.create_and_poll( |
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
75 thread_id=thread.id, assistant_id=assistant.id |
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
76 ) |
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
77 assistant_messages = list( |
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
78 client.beta.threads.messages.list(thread_id=thread.id, run_id=run.id) |
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
79 ) |
3
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
80 if not assistant_messages: |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
81 print( |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
82 "No output was generated!\nPlease ensure that your OpenAI account has sufficient credits.\n" |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
83 "You can check your balance here: https://platform.openai.com/settings/organization/billing" |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
84 ) |
7770a4bd42e2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit c21d9a2cb410ee30dc47f4a13247862481816266
bgruening
parents:
2
diff
changeset
|
85 sys.exit(1) |
2
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
86 message_content = assistant_messages[0].content[0].text.value |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
87 print("Output has been saved!") |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
88 with open("output.txt", "w") as f: |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
89 f.write(message_content) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
90 |
2
dab494dce303
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit d2d08c3866c0f4a2f10372ae15c5dac5ea2d0bf0
bgruening
parents:
1
diff
changeset
|
91 for image in image_files: |
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
92 client.files.delete(image["image_file"]["file_id"]) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
93 if file_search_file_streams: |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
94 client.beta.vector_stores.delete(vector_store.id) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
95 client.beta.threads.delete(thread.id) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
96 client.beta.assistants.delete(assistant.id) |