ПочатиПочніть безкоштовно

Ще більше відповідей від assistant!

Розширте ваші попередні повідомлення, додавши додаткові приклади, збережені як example1, response1, example2, response2, example3 та response3.

Подивімося, чи зможемо ми змусити цю модель повертати інформацію в бажаному форматі!

Ця вправа є частиною курсу

Робота з DeepSeek у Python

Переглянути курс

Інструкції до вправи

  • Розширте ваші попередні повідомлення, щоб додати додаткові приклади інших країн, які збережені як example1, response1, example2, response2, example3 та response3.

Інтерактивна практична вправа

Спробуйте виконати цю вправу, доповнивши цей зразок коду.

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

response = client.chat.completions.create(
   model="deepseek-ai/DeepSeek-V4-Pro",
   # Add in the extra examples and responses
   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 Portugal."},
       {"role": "assistant", "content": "Portugal is a country in Europe that borders Spain. The capital city is Lisboa."},
       {"role": "user", "content": ____},
       {"role": "assistant", "content": ____},
       {"role": "user", "content": ____},
       {"role": "assistant", "content": ____},
       {"role": "user", "content": ____},
       {"role": "assistant", "content": ____},
       {"role": "user", "content": "Give me a quick summary of Greece."}
   ]
)

print(response.choices[0].message.content)
Редагувати та запускати код