mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-09 23:25:58 +00:00
blacken-docs formatting for OpenAI API docs
Signed-off-by: Ben Browning <bbrownin@redhat.com>
This commit is contained in:
parent
d8f8dba2e0
commit
09ab94b8ab
1 changed files with 19 additions and 37 deletions
|
@ -14,6 +14,7 @@ When using the Llama Stack client, set the `base_url` to the root of your Llama
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from llama_stack_client import LlamaStackClient
|
from llama_stack_client import LlamaStackClient
|
||||||
|
|
||||||
client = LlamaStackClient(base_url="http://localhost:8321")
|
client = LlamaStackClient(base_url="http://localhost:8321")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ When using an OpenAI client, set the `base_url` to the `/v1/openai/v1` path on y
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
|
|
||||||
client = OpenAI(base_url="http://localhost:8321/v1/openai/v1", api_key="none")
|
client = OpenAI(base_url="http://localhost:8321/v1/openai/v1", api_key="none")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -70,12 +72,12 @@ response = client.responses.create(
|
||||||
input=[
|
input=[
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"content": "Extract the participants from the event information."
|
"content": "Extract the participants from the event information.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
"content": "Alice and Bob are going to a science fair on Friday."
|
"content": "Alice and Bob are going to a science fair on Friday.",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
text={
|
text={
|
||||||
"format": {
|
"format": {
|
||||||
|
@ -84,19 +86,12 @@ response = client.responses.create(
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"participants": {
|
"participants": {"type": "array", "items": {"type": "string"}}
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"required": [
|
"required": ["participants"],
|
||||||
"participants"
|
},
|
||||||
],
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
print(response.output_text)
|
print(response.output_text)
|
||||||
```
|
```
|
||||||
|
@ -114,12 +109,7 @@ Request:
|
||||||
```python
|
```python
|
||||||
chat_completion = client.chat.completions.create(
|
chat_completion = client.chat.completions.create(
|
||||||
model="meta-llama/Llama-3.2-3B-Instruct",
|
model="meta-llama/Llama-3.2-3B-Instruct",
|
||||||
messages=[
|
messages=[{"role": "user", "content": "Write a haiku about coding."}],
|
||||||
{
|
|
||||||
"role": "user",
|
|
||||||
"content": "Write a haiku about coding."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
print(chat_completion.choices[0].message.content)
|
print(chat_completion.choices[0].message.content)
|
||||||
|
@ -143,12 +133,12 @@ chat_completion = client.chat.completions.create(
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"content": "Extract the participants from the event information."
|
"content": "Extract the participants from the event information.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
"content": "Alice and Bob are going to a science fair on Friday."
|
"content": "Alice and Bob are going to a science fair on Friday.",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
response_format={
|
response_format={
|
||||||
"type": "json_schema",
|
"type": "json_schema",
|
||||||
|
@ -157,19 +147,12 @@ chat_completion = client.chat.completions.create(
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"participants": {
|
"participants": {"type": "array", "items": {"type": "string"}}
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"required": [
|
"required": ["participants"],
|
||||||
"participants"
|
},
|
||||||
],
|
},
|
||||||
}
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
print(chat_completion.choices[0].message.content)
|
print(chat_completion.choices[0].message.content)
|
||||||
|
@ -189,8 +172,7 @@ Request:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
completion = client.completions.create(
|
completion = client.completions.create(
|
||||||
model="meta-llama/Llama-3.2-3B-Instruct",
|
model="meta-llama/Llama-3.2-3B-Instruct", prompt="Write a haiku about coding."
|
||||||
prompt="Write a haiku about coding."
|
|
||||||
)
|
)
|
||||||
|
|
||||||
print(completion.choices[0].text)
|
print(completion.choices[0].text)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue