docs: update API Reference chatCompletions from DevDocs (#2171)
docs: update API Reference chatCompletions from DevDocs
This commit is contained in:
commit
d6ccda051a
@ -93,6 +93,110 @@ paths:
|
||||
"temperature": 0.7,
|
||||
"top_p": 0.95
|
||||
}'
|
||||
- lang: JavaScript
|
||||
source: |-
|
||||
const data = {
|
||||
messages: [
|
||||
{
|
||||
content: 'You are a helpful assistant.',
|
||||
role: 'system'
|
||||
},
|
||||
{
|
||||
content: 'Hello!',
|
||||
role: 'user'
|
||||
}
|
||||
],
|
||||
model: 'tinyllama-1.1b',
|
||||
stream: true,
|
||||
max_tokens: 2048,
|
||||
stop: ['hello'],
|
||||
frequency_penalty: 0,
|
||||
presence_penalty: 0,
|
||||
temperature: 0.7,
|
||||
top_p: 0.95
|
||||
};
|
||||
|
||||
fetch('http://localhost:1337/v1/chat/completions', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => console.log(data));
|
||||
- lang: Node.js
|
||||
source: |-
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
const data = {
|
||||
messages: [
|
||||
{
|
||||
content: 'You are a helpful assistant.',
|
||||
role: 'system'
|
||||
},
|
||||
{
|
||||
content: 'Hello!',
|
||||
role: 'user'
|
||||
}
|
||||
],
|
||||
model: 'tinyllama-1.1b',
|
||||
stream: true,
|
||||
max_tokens: 2048,
|
||||
stop: ['hello'],
|
||||
frequency_penalty: 0,
|
||||
presence_penalty: 0,
|
||||
temperature: 0.7,
|
||||
top_p: 0.95
|
||||
};
|
||||
|
||||
fetch('http://localhost:1337/v1/chat/completions', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => console.log(data));
|
||||
- lang: Python
|
||||
source: >-
|
||||
import requests
|
||||
|
||||
import json
|
||||
|
||||
|
||||
data = {
|
||||
"messages": [
|
||||
{
|
||||
"content": "You are a helpful assistant.",
|
||||
"role": "system"
|
||||
},
|
||||
{
|
||||
"content": "Hello!",
|
||||
"role": "user"
|
||||
}
|
||||
],
|
||||
"model": "tinyllama-1.1b",
|
||||
"stream": true,
|
||||
"max_tokens": 2048,
|
||||
"stop": [
|
||||
"hello"
|
||||
],
|
||||
"frequency_penalty": 0,
|
||||
"presence_penalty": 0,
|
||||
"temperature": 0.7,
|
||||
"top_p": 0.95
|
||||
}
|
||||
|
||||
|
||||
response =
|
||||
requests.post('http://localhost:1337/v1/chat/completions',
|
||||
json=data)
|
||||
|
||||
print(response.json())
|
||||
/models:
|
||||
get:
|
||||
operationId: listModels
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user