Skip to content

Instantly share code, notes, and snippets.

@Vladislav-Melenchuk
Created February 8, 2026 22:01
Show Gist options
  • Select an option

  • Save Vladislav-Melenchuk/7bba273fa1100216fa6720461e0386f4 to your computer and use it in GitHub Desktop.

Select an option

Save Vladislav-Melenchuk/7bba273fa1100216fa6720461e0386f4 to your computer and use it in GitHub Desktop.
CloudsHW

Завдання

Напишите Python-скрипт, который получает текст от пользователя, отправляет его в Azure OpenAI с моделью GPT-4 или GPT-3.5 и получает два результата: краткий пересказ текста и три вопроса по тексту. Скрипт выводит оба результата в консоль.


Создал Asure OpenAi

image

Выбрал модель

image

Результат кода

image

Код

from openai import AzureOpenAI

endpoint = "https://hw11ai.cognitiveservices.azure.com/"
deployment = "helper"        
api_key = ""
api_version = "2024-12-01-preview"

client = AzureOpenAI(
    api_version=api_version,
    azure_endpoint=endpoint,
    api_key=api_key,
)


text = input("Введите текст:\n")

prompt = f"""
Прочитай текст и выполни задания.

Текст:
{text}

Задания:
1. Сделай краткий пересказ текста (2–3 предложения)
2. Составь три вопроса по тексту

Формат ответа:
Краткий пересказ:
...

Вопросы:
1.
2.
3.
"""

response = client.chat.completions.create(
    model=deployment,
    messages=[
        {"role": "system", "content": "Ты помощник для анализа текста."},
        {"role": "user", "content": prompt}
    ],
    temperature=0.5,
    max_tokens=400
)

print("\n=== РЕЗУЛЬТАТ ===\n")
print(response.choices[0].message.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment