찾기 및 바꾸기
찾기 및 바꾸기 도구는 수십 년간 사용되어 왔지만, 정확한 단어나 구문을 찾아 바꾸는 데만 제한적으로 활용되어 왔습니다. 자동차에 관한 텍스트가 제공되었으니, 채팅 완성 모델을 사용하여 이 텍스트를 비행기에 관한 내용으로 적절히 수정해 보겠습니다.
이 연습은 강의의 일부입니다
Python으로 DeepSeek 활용하기
연습 안내
- 자동차에 관한 텍스트를 비행기 내용으로 변환하도록
prompt를deepseek-ai/DeepSeek-V4-Pro에 전송하는 요청을 생성하세요. 최대 토큰 수는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-Pro",
messages=[{"role": "user", "____": ____}],
____
)
# Extract and print the response text
print(response.choices[0].____.____)