Přizpůsobení Copilota

Software Development with GitHub Copilot

Thalia Barrera

AI Engineering Curriculum Manager, DataCamp

Software Development with GitHub Copilot

Software Development with GitHub Copilot

Software Development with GitHub Copilot

Software Development with GitHub Copilot

Jak fungují vlastní instrukce

$$

Definujte:

  • Konvence kódování
  • Preferované nástroje
  • Kontext projektu

Software Development with GitHub Copilot

Jak fungují vlastní instrukce

$$

Definujte:

  • Konvence kódování
  • Preferované nástroje
  • Kontext projektu

Software Development with GitHub Copilot

Jak definovat vlastní instrukce

Umístěte je do: .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...
Software Development with GitHub Copilot

Co dělá instrukci efektivní

$$

✅ Efektivní instrukce:

  • Stručné a konkrétní
  • Soběstačné
  • Obsahují kontext nebo relevantní informace

$$

❌ Neefektivní instrukce:

  • Externí dokumenty nebo repozitáře
  • Specifický tón nebo styl psaní
  • Omezení délky nebo formátování
1 https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions
Software Development with 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

Software Development with 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

Software Development with GitHub Copilot

Jak povolit vlastní instrukce

  • Uložte soubor copilot-instructions.md
  • Bude automaticky zahrnut do vašich promptů

Software Development with GitHub Copilot

Jak povolit vlastní instrukce

  • Uložte soubor copilot-instructions.md
  • Bude automaticky zahrnut do vašich promptů

Software Development with GitHub Copilot

Použití více souborů s instrukcemi

Software Development with GitHub Copilot

Použití více souborů s instrukcemi

Software Development with GitHub Copilot

Použití více souborů s instrukcemi

$$

Software Development with GitHub Copilot

Nastavení instrukcí na úrovni organizace

$$

Software Development with GitHub Copilot

Nastavení instrukcí na úrovni organizace

$$

Příklady celofiremních pravidel:

  • Používání interních nástrojů
  • Vynucení konkrétních knihoven
  • Konzistentní styl kódu
  • Varování při zastaralých vzorech
Software Development with GitHub Copilot

Priorita víceúrovňových instrukcí

$$

$$

$$

Rozsah Priorita
Osobní instrukce Nejvyšší
Instrukce projektu Střední
Instrukce organizace Nejnižší
Software Development with GitHub Copilot

$$

Příklad promptu: "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)
Software Development with GitHub Copilot

$$

Příklad promptu: "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)

$$

Software Development with GitHub Copilot

Pojďme si procvičit!

Software Development with GitHub Copilot

Preparing Video For Download...