Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,6 +17,8 @@ def ask_openai_with_image(instruction, image):
|
|
| 17 |
|
| 18 |
# Убираем пробелы с начала и конца инструкции
|
| 19 |
instruction = instruction.strip()
|
|
|
|
|
|
|
| 20 |
if image != None:
|
| 21 |
# Кодируем загруженное изображение в base64
|
| 22 |
base64_image = encode_image_to_base64(image)
|
|
@@ -26,6 +28,10 @@ def ask_openai_with_image(instruction, image):
|
|
| 26 |
payload = {
|
| 27 |
"model": "gpt-4-vision-preview",
|
| 28 |
"messages": [
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
{
|
| 30 |
"role": "user",
|
| 31 |
"content": instruction,
|
|
@@ -43,6 +49,10 @@ def ask_openai_with_image(instruction, image):
|
|
| 43 |
payload = {
|
| 44 |
"model": "gpt-4-vision-preview",
|
| 45 |
"messages": [
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
{
|
| 47 |
"role": "user",
|
| 48 |
"content": instruction,
|
|
@@ -84,9 +94,9 @@ def ask_openai_with_image(instruction, image):
|
|
| 84 |
with gr.Blocks() as demo:
|
| 85 |
with gr.Row():
|
| 86 |
with gr.Column():
|
| 87 |
-
instructions = gr.Textbox(label="
|
| 88 |
-
image_input = gr.Image(label="
|
| 89 |
-
submit_button = gr.Button("
|
| 90 |
with gr.Column():
|
| 91 |
output_markdown = gr.Markdown(label="AI Response")
|
| 92 |
|
|
|
|
| 17 |
|
| 18 |
# Убираем пробелы с начала и конца инструкции
|
| 19 |
instruction = instruction.strip()
|
| 20 |
+
start = f"Ты помощник студентов. Ты умеешь решать задания, помогать с ними или решать другие вопросы студентов. Ты добрый, приветливый и понятный для студентов любого возраста. Если тебе отправят фото, то ты должен будешь решить задание с фото. Решай правильно, понятно и красиво. Можно отвечать с markdown."
|
| 21 |
+
|
| 22 |
if image != None:
|
| 23 |
# Кодируем загруженное изображение в base64
|
| 24 |
base64_image = encode_image_to_base64(image)
|
|
|
|
| 28 |
payload = {
|
| 29 |
"model": "gpt-4-vision-preview",
|
| 30 |
"messages": [
|
| 31 |
+
{
|
| 32 |
+
"role": "user",
|
| 33 |
+
"content": start,
|
| 34 |
+
},
|
| 35 |
{
|
| 36 |
"role": "user",
|
| 37 |
"content": instruction,
|
|
|
|
| 49 |
payload = {
|
| 50 |
"model": "gpt-4-vision-preview",
|
| 51 |
"messages": [
|
| 52 |
+
{
|
| 53 |
+
"role": "user",
|
| 54 |
+
"content": start,
|
| 55 |
+
},
|
| 56 |
{
|
| 57 |
"role": "user",
|
| 58 |
"content": instruction,
|
|
|
|
| 94 |
with gr.Blocks() as demo:
|
| 95 |
with gr.Row():
|
| 96 |
with gr.Column():
|
| 97 |
+
instructions = gr.Textbox(label="Дополнительный ввод")
|
| 98 |
+
image_input = gr.Image(label="Фото задания", type="pil")
|
| 99 |
+
submit_button = gr.Button("Решить")
|
| 100 |
with gr.Column():
|
| 101 |
output_markdown = gr.Markdown(label="AI Response")
|
| 102 |
|