from litellm import completion
import os
API_BASE = os.environ.get("INCREDIBLE_API_BASE", "https://api.incredible.one/v1")
API_KEY = os.environ.get("INCREDIBLE_API_KEY")
if not API_KEY:
raise RuntimeError("Set INCREDIBLE_API_KEY before running this example")
examples = [
(
"Friendly persona",
[
{
"role": "system",
"content": (
"You are an enthusiastic assistant that always keeps answers concise, friendly,"
" and formatted with exactly two bullet points using bolded headings, followed by"
" a one-sentence closing remark."
),
},
{"role": "user", "content": "Hello there!"},
{
"role": "assistant",
"content": "Hi! It's great to meet you. How can I support your planning or analysis today?",
},
{
"role": "user",
"content": "Give me two bullet points about why streaming demos are useful.",
},
],
0.2,
),
(
"Terse response",
[
{
"role": "system",
"content": (
"You must answer every request in exactly one word."
" The word must be lowercase, contain no punctuation, and convey the best possible answer."
" If the request cannot be satisfied with a single word, reply with 'unknown'."
),
},
{
"role": "user",
"content": "Give me two bullet points about why streaming demos are useful.",
},
],
0.0,
),
(
"Assistant-context",
[
{
"role": "system",
"content": "You are a factual assistant who trusts previous assistant messages as ground truth.",
},
{
"role": "assistant",
"content": "Status update: The system just deployed version 1.2.7 successfully.",
},
{
"role": "user",
"content": "What version is currently live?",
},
],
0.2,
),
]
for label, messages, temperature in examples:
response = completion(
model="openai/small-1",
api_base=API_BASE,
api_key=API_KEY,
messages=messages,
temperature=temperature,
)
choice = response.choices[0]
print(f"\n{label} role: {choice.message.role}")
print(f"{label} content:\n{choice.message.content}")