Update app.py
Browse files
app.py
CHANGED
|
@@ -180,7 +180,7 @@ def process_image(image_path, prompt):
|
|
| 180 |
"content": [
|
| 181 |
{
|
| 182 |
"type": "text",
|
| 183 |
-
"text": prompt
|
| 184 |
},
|
| 185 |
{
|
| 186 |
"type": "image_url",
|
|
@@ -212,11 +212,7 @@ def generate_auswahl(prompt, file, chatbot, history, rag_option, model_option, o
|
|
| 212 |
#geht nur über spezielle OpenAI-Schnittstelle...
|
| 213 |
result= generate_text_zu_bild(file, prompt, k, rag_option, chatbot)
|
| 214 |
history = history + [((file,), None),(prompt, result)]
|
| 215 |
-
|
| 216 |
-
print("result..................")
|
| 217 |
-
print(result)
|
| 218 |
-
print("history.......................")
|
| 219 |
-
print(chatbot)
|
| 220 |
chatbot[-1][1] = ""
|
| 221 |
for character in result:
|
| 222 |
chatbot[-1][1] += character
|
|
@@ -232,6 +228,7 @@ def generate_auswahl(prompt, file, chatbot, history, rag_option, model_option, o
|
|
| 232 |
##################################################
|
| 233 |
#zu einem Text-Prompt ein Bild via Stable Diffusion generieren
|
| 234 |
def generate_bild(prompt, chatbot, temperature=0.5, max_new_tokens=4048,top_p=0.6, repetition_penalty=1.3):
|
|
|
|
| 235 |
#Bild nach Anweisung zeichnen und in History darstellen...
|
| 236 |
data = {"inputs": prompt}
|
| 237 |
response = requests.post(API_URL, headers=HEADERS, json=data)
|
|
@@ -249,9 +246,10 @@ def generate_bild(prompt, chatbot, temperature=0.5, max_new_tokens=4048,top_p=0
|
|
| 249 |
#zu einem Bild und Text-Prompt eine Analyse generieren
|
| 250 |
def generate_text_zu_bild(file, prompt, k, rag_option, chatbot):
|
| 251 |
global splittet
|
| 252 |
-
|
| 253 |
prompt_neu = prompt
|
| 254 |
if (rag_option == "An"):
|
|
|
|
| 255 |
#muss nur einmal ausgeführt werden...
|
| 256 |
if not splittet:
|
| 257 |
splits = document_loading_splitting()
|
|
@@ -277,7 +275,7 @@ def generate_text_zu_bild(file, prompt, k, rag_option, chatbot):
|
|
| 277 |
#mit oder ohne RAG möglich
|
| 278 |
def generate_text (prompt, chatbot, history, rag_option, model_option, openai_api_key, k=3, top_p=0.6, temperature=0.5, max_new_tokens=4048, max_context_length_tokens=2048, repetition_penalty=1.3,):
|
| 279 |
global splittet
|
| 280 |
-
|
| 281 |
if (openai_api_key == "" or openai_api_key == "sk-"):
|
| 282 |
#raise gr.Error("OpenAI API Key is required.")
|
| 283 |
#eigenen OpenAI key nutzen
|
|
|
|
| 180 |
"content": [
|
| 181 |
{
|
| 182 |
"type": "text",
|
| 183 |
+
"text": llm_template + prompt
|
| 184 |
},
|
| 185 |
{
|
| 186 |
"type": "image_url",
|
|
|
|
| 212 |
#geht nur über spezielle OpenAI-Schnittstelle...
|
| 213 |
result= generate_text_zu_bild(file, prompt, k, rag_option, chatbot)
|
| 214 |
history = history + [((file,), None),(prompt, result)]
|
| 215 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
chatbot[-1][1] = ""
|
| 217 |
for character in result:
|
| 218 |
chatbot[-1][1] += character
|
|
|
|
| 228 |
##################################################
|
| 229 |
#zu einem Text-Prompt ein Bild via Stable Diffusion generieren
|
| 230 |
def generate_bild(prompt, chatbot, temperature=0.5, max_new_tokens=4048,top_p=0.6, repetition_penalty=1.3):
|
| 231 |
+
print("Bild Erzeugung..............................")
|
| 232 |
#Bild nach Anweisung zeichnen und in History darstellen...
|
| 233 |
data = {"inputs": prompt}
|
| 234 |
response = requests.post(API_URL, headers=HEADERS, json=data)
|
|
|
|
| 246 |
#zu einem Bild und Text-Prompt eine Analyse generieren
|
| 247 |
def generate_text_zu_bild(file, prompt, k, rag_option, chatbot):
|
| 248 |
global splittet
|
| 249 |
+
print("text mit Bild ..............................")
|
| 250 |
prompt_neu = prompt
|
| 251 |
if (rag_option == "An"):
|
| 252 |
+
print("Bild mit RAG..............................")
|
| 253 |
#muss nur einmal ausgeführt werden...
|
| 254 |
if not splittet:
|
| 255 |
splits = document_loading_splitting()
|
|
|
|
| 275 |
#mit oder ohne RAG möglich
|
| 276 |
def generate_text (prompt, chatbot, history, rag_option, model_option, openai_api_key, k=3, top_p=0.6, temperature=0.5, max_new_tokens=4048, max_context_length_tokens=2048, repetition_penalty=1.3,):
|
| 277 |
global splittet
|
| 278 |
+
print("Text pur..............................")
|
| 279 |
if (openai_api_key == "" or openai_api_key == "sk-"):
|
| 280 |
#raise gr.Error("OpenAI API Key is required.")
|
| 281 |
#eigenen OpenAI key nutzen
|