시작하기무료로 시작하기

찾아서 바꾸기

찾아서 바꾸기 도구는 수십 년 전부터 존재해 왔지만, 대개는 정확히 일치하는 단어나 문구를 찾아 바꾸는 데에만 한정되어 있습니다. 자동차에 관한 텍스트 블록이 주어졌을 때, 채팅 완성 모델을 사용해 이 텍스트를 비행기에 관한 내용으로 적절히 바꿔보세요.

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

Python으로 DeepSeek 활용하기

강의 보기

연습 안내

  • deepseek-ai/DeepSeek-V4.1-Flash에 prompt를 전달하는 요청을 생성하여, 자동차에 관한 텍스트를 비행기에 관한 내용으로 바꾸세요. 최대 토큰 수는 100으로 설정하세요.
  • API의 텍스트 응답을 추출하여 출력하세요.

실습형 인터랙티브 연습

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

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

prompt="""Replace car with plane and adjust phrase:
A car is a vehicle that is typically powered by an internal combustion engine or an electric motor. It has four wheels, and is designed to carry passengers and/or cargo on roads or highways. Cars have become a ubiquitous part of modern society, and are used for a wide variety of purposes, such as commuting, travel, and transportation of goods. Cars are often associated with freedom, independence, and mobility."""

# Create a request to the chat model
response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V4.1-Flash",
  messages=[{"role": "user", "____": ____}],
  ____
)

# Extract and print the response text
print(response.choices[0].____.____)
코드 편집 및 실행