Update app.py
Browse files
app.py
CHANGED
|
@@ -211,7 +211,9 @@ def create_assistant(prompt, file):
|
|
| 211 |
assistant = client.beta.assistants.update(assistant.id,tools=[{"type": "code_interpreter"}, {"type": "retrieval"}],file_ids=[file_neu.id],)
|
| 212 |
thread, run = create_thread_and_run(prompt)
|
| 213 |
run = wait_on_run(run, thread)
|
| 214 |
-
|
|
|
|
|
|
|
| 215 |
|
| 216 |
###################################################
|
| 217 |
#Funktion von Gradio aus, die den dort eingegebenen Prompt annimmt und weiterverarbeitet
|
|
@@ -320,19 +322,9 @@ def generate_text_zu_doc(file, prompt, k, rag_option, chatbot):
|
|
| 320 |
#prompt = generate_prompt_with_history_openai(neu_text_mit_chunks, history)
|
| 321 |
#als reiner prompt:
|
| 322 |
prompt_neu = generate_prompt_with_history(neu_text_mit_chunks, chatbot)
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
create_assistant(prompt_neu, file)
|
| 326 |
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
headers, payload = process_image(file, prompt_neu)
|
| 330 |
-
response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
|
| 331 |
-
#als json ausgeben
|
| 332 |
-
data = response.json()
|
| 333 |
-
# Den "content" auswählen, da dort die Antwort der Ki enthalten ist
|
| 334 |
-
result = data['choices'][0]['message']['content']
|
| 335 |
-
return result
|
| 336 |
|
| 337 |
|
| 338 |
####################################################
|
|
|
|
| 211 |
assistant = client.beta.assistants.update(assistant.id,tools=[{"type": "code_interpreter"}, {"type": "retrieval"}],file_ids=[file_neu.id],)
|
| 212 |
thread, run = create_thread_and_run(prompt)
|
| 213 |
run = wait_on_run(run, thread)
|
| 214 |
+
response = get_response(thread))
|
| 215 |
+
result = assistant.content[0].text.value
|
| 216 |
+
return result
|
| 217 |
|
| 218 |
###################################################
|
| 219 |
#Funktion von Gradio aus, die den dort eingegebenen Prompt annimmt und weiterverarbeitet
|
|
|
|
| 322 |
#prompt = generate_prompt_with_history_openai(neu_text_mit_chunks, history)
|
| 323 |
#als reiner prompt:
|
| 324 |
prompt_neu = generate_prompt_with_history(neu_text_mit_chunks, chatbot)
|
|
|
|
|
|
|
|
|
|
| 325 |
|
| 326 |
+
result = create_assistant(prompt_neu, file)
|
| 327 |
+
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
|
| 329 |
|
| 330 |
####################################################
|