Update app.py
Browse files
app.py
CHANGED
|
@@ -213,26 +213,31 @@ def process_image(image_path, prompt):
|
|
| 213 |
##################################################
|
| 214 |
#openassistant um uploaded Files zu analysieren
|
| 215 |
def create_assistant_file(prompt, file):
|
| 216 |
-
global client,
|
| 217 |
#neues File dem Assistant hinzufügen
|
| 218 |
file_neu = client.files.create(file=open(file,"rb",),purpose="assistants",)
|
| 219 |
# Update Assistant
|
| 220 |
#wenn type: code_interpreter, wird das file mit angehängt an den Prpmt, aber vorher nicht bearbeitet
|
| 221 |
#wenn type: retrieval, wird das Dokument vorher embedded in einem vektorstore und nur entsprechende chunks mitgegeben.
|
| 222 |
#pro Assistant 20 cent pro Tag als Nutzung - egal wie viele Fragen dazu.
|
| 223 |
-
updated_assistant = client.beta.assistants.update(
|
| 224 |
-
|
| 225 |
-
run = wait_on_run(run,
|
| 226 |
-
response = get_response(
|
| 227 |
result = response.data[1].content[0].text.value
|
| 228 |
return result
|
| 229 |
|
| 230 |
##################################################
|
| 231 |
#openassistant um im Netz zu suchen
|
| 232 |
def create_assistant_suche(prompt):
|
| 233 |
-
global client
|
| 234 |
#neues File dem Assistant hinzufügen
|
| 235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
return result
|
| 237 |
|
| 238 |
###################################################
|
|
|
|
| 213 |
##################################################
|
| 214 |
#openassistant um uploaded Files zu analysieren
|
| 215 |
def create_assistant_file(prompt, file):
|
| 216 |
+
global client, general_assistant_file
|
| 217 |
#neues File dem Assistant hinzufügen
|
| 218 |
file_neu = client.files.create(file=open(file,"rb",),purpose="assistants",)
|
| 219 |
# Update Assistant
|
| 220 |
#wenn type: code_interpreter, wird das file mit angehängt an den Prpmt, aber vorher nicht bearbeitet
|
| 221 |
#wenn type: retrieval, wird das Dokument vorher embedded in einem vektorstore und nur entsprechende chunks mitgegeben.
|
| 222 |
#pro Assistant 20 cent pro Tag als Nutzung - egal wie viele Fragen dazu.
|
| 223 |
+
updated_assistant = client.beta.assistants.update(general_assistant_file.id,tools=[{"type": "code_interpreter"}, {"type": "retrieval"}],file_ids=[file_neu.id],)
|
| 224 |
+
thread_file, run = create_thread_and_run(prompt, client, updated_assistant.id)
|
| 225 |
+
run = wait_on_run(run, thread_file, client)
|
| 226 |
+
response = get_response(thread_file, client, updated_assistant.id)
|
| 227 |
result = response.data[1].content[0].text.value
|
| 228 |
return result
|
| 229 |
|
| 230 |
##################################################
|
| 231 |
#openassistant um im Netz zu suchen
|
| 232 |
def create_assistant_suche(prompt):
|
| 233 |
+
global client
|
| 234 |
#neues File dem Assistant hinzufügen
|
| 235 |
+
assistant_suche =openai_assistant_suche(client, template)
|
| 236 |
+
thread_suche, run = create_thread_and_run(prompt, client, assistant_suche.id)
|
| 237 |
+
run = wait_on_run(run, thread_suche, client)
|
| 238 |
+
response = get_response(thread_suche, client, assistant_suche.id)
|
| 239 |
+
result = response.data[1].content[0].text.value
|
| 240 |
+
|
| 241 |
return result
|
| 242 |
|
| 243 |
###################################################
|