| 12345678910111213141516171819202122232425262728293031323334 |
- from openai import OpenAI
- SCW_API_KEY = "ad99d6a9-b71e-457d-855a-4d4b5f9abdda"
- SCW_MODEL = "mistral-small-3.2-24b-instruct-2506"
- BASE_URL = "https://api.scaleway.ai/d7d5949a-c2bb-484a-b973-e05a83510efd/v1"
- client = OpenAI(
- base_url=BASE_URL,
- api_key=SCW_API_KEY
- )
- print(f"Appel vers : {BASE_URL}")
- print(f"Modèle : {SCW_MODEL}\n")
- print("Réponse du modèle : ", end="", flush=True)
- response = client.chat.completions.create(
- model=SCW_MODEL,
- messages=[
- {"role": "system", "content": "You are a helpful assistant"},
- {"role": "user", "content": "Dis bonjour en une phrase."}
- ],
- max_tokens=512,
- temperature=0.15,
- top_p=1,
- presence_penalty=0,
- stream=True,
- response_format={"type": "text"}
- )
- for chunk in response:
- if chunk.choices and chunk.choices[0].delta.content:
- print(chunk.choices[0].delta.content, end="", flush=True)
- print()
|