Mercurial > repos > bgruening > chatgpt_openai_api
annotate chatgpt.py @ 0:f256dc85e1a0 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
author | bgruening |
---|---|
date | Tue, 13 Aug 2024 14:25:19 +0000 |
parents | |
children | 08c658e9aa9e |
rev | line source |
---|---|
0
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
1 import os |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
2 import sys |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
3 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
4 from openai import OpenAI |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
5 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
6 context_files = sys.argv[1].split(",") |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
7 question = sys.argv[2] |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
8 model = sys.argv[3] |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
9 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
|
10 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
|
11 if not openai_api_key: |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
12 raise Exception("OpenAI API key is not provided in user preferences!") |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
13 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
14 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
|
15 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
16 file_search_sup_ext = [ |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
17 "c", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
18 "cs", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
19 "cpp", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
20 "doc", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
21 "docx", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
22 "html", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
23 "java", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
24 "json", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
25 "md", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
26 "pdf", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
27 "php", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
28 "pptx", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
29 "py", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
30 "rb", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
31 "tex", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
32 "txt", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
33 "css", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
34 "js", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
35 "sh", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
36 "ts", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
37 ] |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
38 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
39 vision_sup_ext = ["jpg", "jpeg", "png", "webp", "gif"] |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
40 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
41 file_search_file_streams = [] |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
42 image_urls = [] |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
43 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
44 for path in context_files: |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
45 ext = path.split(".")[-1].lower() |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
46 if ext in vision_sup_ext and model in ["gpt-4o", "gpt-4o-mini", "gpt-4-turbo"]: |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
47 if os.path.getsize(path) > 20 * 1024 * 1024: |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
48 raise Exception(f"File {path} exceeds the 20MB limit and will not be processed.") |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
49 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
|
50 promt = {"type": "image_file", "image_file": {"file_id": file.id}} |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
51 image_urls.append(promt) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
52 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
53 elif ext in file_search_sup_ext: |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
54 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
|
55 else: |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
56 raise Exception("Not supported file!") |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
57 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
58 assistant = client.beta.assistants.create( |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
59 instructions="You are going to get question about the file(s).", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
60 model=model, |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
61 tools=[{"type": "file_search"}] if file_search_file_streams else None, |
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 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
|
64 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
|
65 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
|
66 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
|
67 ) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
68 assistant = client.beta.assistants.update( |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
69 assistant_id=assistant.id, tool_resources={"file_search": {"vector_store_ids": [vector_store.id]}} |
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 messages = [ |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
73 { |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
74 "role": "user", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
75 "content": [ |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
76 { |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
77 "type": "text", |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
78 "text": question, |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
79 }, |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
80 *image_urls, |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
81 ], |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
82 } |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
83 ] |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
84 thread = client.beta.threads.create(messages=messages) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
85 run = client.beta.threads.runs.create_and_poll(thread_id=thread.id, assistant_id=assistant.id) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
86 messages = list(client.beta.threads.messages.list(thread_id=thread.id, run_id=run.id)) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
87 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
88 message_content = messages[0].content[0].text.value |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
89 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
|
90 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
|
91 f.write(message_content) |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
92 |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
93 for image in image_urls: |
f256dc85e1a0
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/chatgpt commit 840e66e7f23cf775ebd3083c6e07d1819b17f74c
bgruening
parents:
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 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
|
98 client.beta.assistants.delete(assistant.id) |