From 0e79344ddb658309a9a72ffe9cc496e21a45822b Mon Sep 17 00:00:00 2001 From: Vincent Young Date: Tue, 2 Apr 2024 15:10:38 -0400 Subject: [PATCH] Create example.js --- example.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 example.js diff --git a/example.js b/example.js new file mode 100644 index 0000000..2abffb3 --- /dev/null +++ b/example.js @@ -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); + });