mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-17 10:59:48 +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):
|
||||
content: str
|
||||
additional_info: str
|
||||
recipe_name: str
|
||||
ingredients: list[str]
|
||||
steps: list[str]
|
||||
|
||||
|
||||
response = client.inference.chat_completion(
|
||||
model_id=os.environ["INFERENCE_MODEL"],
|
||||
messages=[
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
{"role": "user", "content": "Write a haiku about coding"},
|
||||
{"role": "system", "content": "You are a chef."},
|
||||
{"role": "user", "content": "Give me a recipe for spaghetti bolognaise"},
|
||||
],
|
||||
response_format={
|
||||
"type": "json_schema",
|
||||
"json_schema": CompletionMessage.model_json_schema(),
|
||||
},
|
||||
sampling_params={"max_tokens": 8000},
|
||||
)
|
||||
print(response.completion_message.content)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue