Налаштування Copilot

Розробка програмного забезпечення з GitHub Copilot

Thalia Barrera

AI Engineering Curriculum Manager, DataCamp

Розробка програмного забезпечення з GitHub Copilot

Розробка програмного забезпечення з GitHub Copilot

Розробка програмного забезпечення з GitHub Copilot

Розробка програмного забезпечення з GitHub Copilot

Як працюють власні інструкції

$$

Визначте:

  • Правила кодування
  • Уподобання інструментів
  • Контекст проєкту

Розробка програмного забезпечення з GitHub Copilot

Як працюють власні інструкції

$$

Визначте:

  • Правила кодування
  • Уподобання інструментів
  • Контекст проєкту

Розробка програмного забезпечення з GitHub Copilot

Як визначити власні інструкції

Додайте їх до: .github/copilot-instructions.md

## Project context
Python project for processing data pipelines with Airflow.

## Coding style - Use type hints for all functions
- Follow PEP8
- Use snake_case naming
- Write Google-style docstrings
## Testing - Use pytest
- Include one test per function
## More instructions...
Розробка програмного забезпечення з GitHub Copilot

Що робить інструкцію ефективною

$$

✅ Ефективні інструкції:

  • Короткі й конкретні
  • Самодостатні
  • Додають контекст або релевантні дані

$$

❌ Неефективні інструкції:

  • Зовнішні документи чи репозиторії
  • Заданий тон або стиль письма
  • Обмеження на детальність чи форматування
1 https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions
Розробка програмного забезпечення з GitHub Copilot

$$

$$

## Style guidelines

- Conform to the coding styles defined 
in styleguide.md in repo my-org/my-repo

- Answer in the style of a friendly 
colleague, using informal language

- Answer in fewer than 1,000 characters

Розробка програмного забезпечення з GitHub Copilot

$$

$$

## Style guidelines

- Conform to the coding styles defined 
in styleguide.md in repo my-org/my-repo

- Answer in the style of a friendly 
colleague, using informal language

- Answer in fewer than 1,000 characters

Розробка програмного забезпечення з GitHub Copilot

Як увімкнути власні інструкції

  • Збережіть файл copilot-instructions.md
  • Його автоматично додадуть до ваших підказок

Розробка програмного забезпечення з GitHub Copilot

Як увімкнути власні інструкції

  • Збережіть файл copilot-instructions.md
  • Його автоматично додадуть до ваших підказок

Розробка програмного забезпечення з GitHub Copilot

Використання кількох файлів інструкцій

Розробка програмного забезпечення з GitHub Copilot

Використання кількох файлів інструкцій

Розробка програмного забезпечення з GitHub Copilot

Використання кількох файлів інструкцій

$$

Розробка програмного забезпечення з GitHub Copilot

Інструкції на рівні організації

$$

Розробка програмного забезпечення з GitHub Copilot

Інструкції на рівні організації

$$

Приклади загально корпоративних правил:

  • Використовувати внутрішні інструменти
  • Обов'язкові певні бібліотеки
  • Єдиний стиль
  • Попереджати про застарілі підходи
Розробка програмного забезпечення з GitHub Copilot

Пріоритет багаторівневих інструкцій

$$

$$

$$

Scope Priority
Personal instructions Highest
Project instructions Medium
Organization instructions Lowest
Розробка програмного забезпечення з GitHub Copilot

$$

Приклад підказки: "Write a function that calculates the average of a list of numbers."

def calculate_average(numbers: List[float]) -> float:
    """Calculate the average of a list of numbers.

    Args:
        numbers (List[float]): A list of numbers to average.

    Returns:
        float: The average value of the numbers.

    Raises:
        ValueError: If the list is empty.
    """
    if not numbers:
        raise ValueError("The list of numbers cannot be empty.")
    return sum(numbers) / len(numbers)
Розробка програмного забезпечення з GitHub Copilot

$$

Приклад підказки: "Write a function that calculates the average of a list of numbers."

def calculate_average(numbers: List[float]) -> float:
    """Calculate the average of a list of numbers.

    Args:
        numbers (List[float]): A list of numbers to average.

    Returns:
        float: The average value of the numbers.

    Raises:
        ValueError: If the list is empty.
    """
    if not numbers:
        raise ValueError("The numbers list cannot be empty.")
    return sum(numbers) / len(numbers)

$$

Розробка програмного забезпечення з GitHub Copilot

Давайте потренуємось!

Розробка програмного забезпечення з GitHub Copilot

Preparing Video For Download...