Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,8 @@ def query(prompt, model, is_negative=False, steps=30, cfg_scale=7, sampler="DPM+
|
|
19 |
if prompt == "" or prompt == None:
|
20 |
return None
|
21 |
|
|
|
|
|
22 |
if gpt:
|
23 |
payload = {
|
24 |
"model": "gpt-4-vision-preview",
|
@@ -57,6 +59,7 @@ def query(prompt, model, is_negative=False, steps=30, cfg_scale=7, sampler="DPM+
|
|
57 |
try:
|
58 |
# Пытаемся извлечь текст из ответа
|
59 |
prompt = response_json["choices"][0]["message"]["content"]
|
|
|
60 |
except Exception as e:
|
61 |
print(f"Error processing the image response: {e}")
|
62 |
else:
|
@@ -66,7 +69,6 @@ def query(prompt, model, is_negative=False, steps=30, cfg_scale=7, sampler="DPM+
|
|
66 |
|
67 |
API_TOKEN = random.choice([os.getenv("HF_READ_TOKEN"), os.getenv("HF_READ_TOKEN_2"), os.getenv("HF_READ_TOKEN_3"), os.getenv("HF_READ_TOKEN_4"), os.getenv("HF_READ_TOKEN_5")]) # it is free
|
68 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
69 |
-
key = random.randint(0, 999)
|
70 |
|
71 |
prompt = GoogleTranslator(source='ru', target='en').translate(prompt)
|
72 |
print(f'\033[1mГенерация {key} перевод:\033[0m {prompt}')
|
|
|
19 |
if prompt == "" or prompt == None:
|
20 |
return None
|
21 |
|
22 |
+
key = random.randint(0, 999)
|
23 |
+
|
24 |
if gpt:
|
25 |
payload = {
|
26 |
"model": "gpt-4-vision-preview",
|
|
|
59 |
try:
|
60 |
# Пытаемся извлечь текст из ответа
|
61 |
prompt = response_json["choices"][0]["message"]["content"]
|
62 |
+
print(f'Генерация {key} gpt: {prompt}')
|
63 |
except Exception as e:
|
64 |
print(f"Error processing the image response: {e}")
|
65 |
else:
|
|
|
69 |
|
70 |
API_TOKEN = random.choice([os.getenv("HF_READ_TOKEN"), os.getenv("HF_READ_TOKEN_2"), os.getenv("HF_READ_TOKEN_3"), os.getenv("HF_READ_TOKEN_4"), os.getenv("HF_READ_TOKEN_5")]) # it is free
|
71 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
|
|
72 |
|
73 |
prompt = GoogleTranslator(source='ru', target='en').translate(prompt)
|
74 |
print(f'\033[1mГенерация {key} перевод:\033[0m {prompt}')
|