Dostosowywanie Copilota

Programowanie z GitHub Copilot

Thalia Barrera

AI Engineering Curriculum Manager, DataCamp

Programowanie z GitHub Copilot

Programowanie z GitHub Copilot

Programowanie z GitHub Copilot

Programowanie z GitHub Copilot

Jak działają niestandardowe instrukcje

$$

Zdefiniuj:

  • Konwencje kodowania
  • Preferencje narzędzi
  • Kontekst projektu

Programowanie z GitHub Copilot

Jak działają niestandardowe instrukcje

$$

Zdefiniuj:

  • Konwencje kodowania
  • Preferencje narzędzi
  • Kontekst projektu

Programowanie z GitHub Copilot

Jak definiować niestandardowe instrukcje

Umieść je w: .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...
Programowanie z GitHub Copilot

Co sprawia, że instrukcja jest skuteczna

$$

✅ Skuteczne instrukcje:

  • Krótkie i konkretne
  • Samodzielne
  • Zawierają kontekst lub istotne informacje

$$

❌ Nieskuteczne instrukcje:

  • Zewnętrzne dokumenty lub repozytoria
  • Określony ton lub styl wypowiedzi
  • Ograniczenia dotyczące szczegółowości lub formatowania
1 https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions
Programowanie z 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

Programowanie z 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

Programowanie z GitHub Copilot

Jak włączyć niestandardowe instrukcje

  • Zapisz plik copilot-instructions.md
  • Zostanie on automatycznie dołączony do Twoich promptów

Programowanie z GitHub Copilot

Jak włączyć niestandardowe instrukcje

  • Zapisz plik copilot-instructions.md
  • Zostanie on automatycznie dołączony do Twoich promptów

Programowanie z GitHub Copilot

Używanie wielu plików instrukcji

Programowanie z GitHub Copilot

Używanie wielu plików instrukcji

Programowanie z GitHub Copilot

Używanie wielu plików instrukcji

$$

Programowanie z GitHub Copilot

Ustawianie instrukcji na poziomie organizacji

$$

Programowanie z GitHub Copilot

Ustawianie instrukcji na poziomie organizacji

$$

Przykłady reguł obowiązujących w całej firmie:

  • Korzystanie z wewnętrznych narzędzi
  • Wymuszanie określonych bibliotek
  • Stosowanie spójnego stylu
  • Ostrzeganie przed przestarzałymi wzorcami
Programowanie z GitHub Copilot

Priorytety instrukcji wielopoziomowych

$$

$$

$$

Zakres Priorytet
Instrukcje osobiste Najwyższy
Instrukcje projektu Średni
Instrukcje organizacji Najniższy
Programowanie z GitHub Copilot

$$

Przykładowy prompt: "Napisz funkcję obliczającą średnią listy liczb."

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)
Programowanie z GitHub Copilot

$$

Przykładowy prompt: "Napisz funkcję obliczającą średnią listy liczb."

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)

$$

Programowanie z GitHub Copilot

Czas na ćwiczenia!

Programowanie z GitHub Copilot

Preparing Video For Download...