mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-17 08:52:39 +00:00
.
This commit is contained in:
parent
f6f3f3c792
commit
85ae899964
1 changed files with 6 additions and 4 deletions
10
1.py
10
1.py
|
|
@ -14,19 +14,21 @@ client = LlamaStackClient(base_url=f"http://localhost:{os.environ['LLAMA_STACK_P
|
||||||
|
|
||||||
|
|
||||||
class CompletionMessage(BaseModel):
|
class CompletionMessage(BaseModel):
|
||||||
content: str
|
recipe_name: str
|
||||||
additional_info: str
|
ingredients: list[str]
|
||||||
|
steps: list[str]
|
||||||
|
|
||||||
|
|
||||||
response = client.inference.chat_completion(
|
response = client.inference.chat_completion(
|
||||||
model_id=os.environ["INFERENCE_MODEL"],
|
model_id=os.environ["INFERENCE_MODEL"],
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "system", "content": "You are a helpful assistant."},
|
{"role": "system", "content": "You are a chef."},
|
||||||
{"role": "user", "content": "Write a haiku about coding"},
|
{"role": "user", "content": "Give me a recipe for spaghetti bolognaise"},
|
||||||
],
|
],
|
||||||
response_format={
|
response_format={
|
||||||
"type": "json_schema",
|
"type": "json_schema",
|
||||||
"json_schema": CompletionMessage.model_json_schema(),
|
"json_schema": CompletionMessage.model_json_schema(),
|
||||||
},
|
},
|
||||||
|
sampling_params={"max_tokens": 8000},
|
||||||
)
|
)
|
||||||
print(response.completion_message.content)
|
print(response.completion_message.content)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue