Tùy chỉnh Copilot

Phát triển phần mềm với GitHub Copilot

Thalia Barrera

AI Engineering Curriculum Manager, DataCamp

Phát triển phần mềm với GitHub Copilot

Phát triển phần mềm với GitHub Copilot

Phát triển phần mềm với GitHub Copilot

Phát triển phần mềm với GitHub Copilot

Cách hoạt động của hướng dẫn tùy chỉnh

$$

Xác định:

  • Quy ước mã hóa
  • Ưu tiên công cụ
  • Ngữ cảnh dự án

Phát triển phần mềm với GitHub Copilot

Cách hoạt động của hướng dẫn tùy chỉnh

$$

Xác định:

  • Quy ước mã hóa
  • Ưu tiên công cụ
  • Ngữ cảnh dự án

Phát triển phần mềm với GitHub Copilot

Cách xác định hướng dẫn tùy chỉnh

Bao gồm trong: .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...
Phát triển phần mềm với GitHub Copilot

Thế nào là hướng dẫn hiệu quả

$$

✅ Hướng dẫn hiệu quả:

  • Ngắn và cụ thể
  • Tự chứa
  • Thêm ngữ cảnh hoặc thông tin liên quan

$$

❌ Hướng dẫn kém hiệu quả:

  • Tài liệu/kho ngoài
  • Yêu cầu giọng điệu hoặc văn phong cụ thể
  • Giới hạn độ chi tiết hoặc định dạng
1 https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions
Phát triển phần mềm với 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

Phát triển phần mềm với 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

Phát triển phần mềm với GitHub Copilot

Cách bật hướng dẫn tùy chỉnh

  • Lưu tệp copilot-instructions.md
  • Tệp sẽ tự động được đưa vào lời nhắc của bạn

Phát triển phần mềm với GitHub Copilot

Cách bật hướng dẫn tùy chỉnh

  • Lưu tệp copilot-instructions.md
  • Tệp sẽ tự động được đưa vào lời nhắc của bạn

Phát triển phần mềm với GitHub Copilot

Dùng nhiều tệp hướng dẫn

Phát triển phần mềm với GitHub Copilot

Dùng nhiều tệp hướng dẫn

Phát triển phần mềm với GitHub Copilot

Dùng nhiều tệp hướng dẫn

$$

Phát triển phần mềm với GitHub Copilot

Thiết lập hướng dẫn cấp tổ chức

$$

Phát triển phần mềm với GitHub Copilot

Thiết lập hướng dẫn cấp tổ chức

$$

Ví dụ quy tắc toàn công ty:

  • Dùng công cụ nội bộ
  • Ép dùng thư viện cụ thể
  • Áp dụng phong cách nhất quán
  • Cảnh báo mẫu lỗi thời
Phát triển phần mềm với GitHub Copilot

Ưu tiên nhiều cấp hướng dẫn

$$

$$

$$

Phạm vi Ưu tiên
Hướng dẫn cá nhân Cao nhất
Hướng dẫn dự án Trung bình
Hướng dẫn tổ chức Thấp nhất
Phát triển phần mềm với GitHub Copilot

$$

Ví dụ lời nhắc: "Viết hàm tính trung bình của một danh sách số."

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)
Phát triển phần mềm với GitHub Copilot

$$

Ví dụ lời nhắc: "Viết hàm tính trung bình của một danh sách số."

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)

$$

Phát triển phần mềm với GitHub Copilot

¡Vamos a practicar!

Phát triển phần mềm với GitHub Copilot

Preparing Video For Download...