mirror of
https://github.com/missuo/FreeGPT35.git
synced 2025-10-13 22:10:56 +00:00
Create example.js
This commit is contained in:
26
example.js
Normal file
26
example.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const axios = require('axios');
|
||||
|
||||
const API_URL = 'http://localhost:3040/v1/chat/completions';
|
||||
|
||||
const prompt = 'Hello, how are you?';
|
||||
|
||||
const data = {
|
||||
model: 'gpt-3.5-turbo',
|
||||
messages: [{ role: 'user', content: prompt }],
|
||||
temperature: 0.7,
|
||||
};
|
||||
|
||||
const config = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
axios
|
||||
.post(API_URL, data, config)
|
||||
.then((response) => {
|
||||
console.log(response.data.choices[0].message.content);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
Reference in New Issue
Block a user