시작하기무료로 시작하기

assistant 메시지 추가하기

채팅 모드는 대화형 애플리케이션을 만들기에 적합하며, 모델이 참고할 대화 예시를 제공하면 성능을 더욱 향상시킬 수 있습니다.

아래의 예시 질문과 이상적인 모델 응답을 메시지에 포함하여 지리 튜터 애플리케이션을 개선해 보세요.

  • 예시 질문: Give me a quick summary of Portugal.
  • 예시 답변: Portugal is a country in Europe that borders Spain. The capital city is Lisboa.

이 연습은 강의의 일부입니다

Python으로 DeepSeek 활용하기

강의 보기

연습 안내

  • 제공된 예시 질문과 답변을 user-assistant 쌍으로 구성하여 모델에 전달하는 메시지에 추가하세요.
    • 예시 질문: Give me a quick summary of Portugal.
    • 예시 답변: Portugal is a country in Europe that borders Spain. The capital city is Lisboa.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

client = OpenAI(api_key="", base_url="https://api.together.xyz/v1")

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Pro",
    # Add a user and assistant message for in-context learning
    messages=[
        {"role": "system", "content": "You are a helpful Geography tutor that generates concise, one-sentence summaries for different countries."},
        ____,
        ____,
        {"role": "user", "content": "Give me a quick summary of Greece."}
    ]
)

print(response.choices[0].message.content)
코드 편집 및 실행