From: lon Date: Sat, 26 Aug 2023 08:07:43 +0000 (+0200) Subject: examples : skip unnecessary external lib in server README.md how-to (#2804) X-Git-Tag: gguf-v0.4.0~236 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=bae5c5f679e043371bc2b4dffff8d4964d6cb953;p=pkg%2Fggml%2Fsources%2Fllama.cpp examples : skip unnecessary external lib in server README.md how-to (#2804) --- diff --git a/examples/server/README.md b/examples/server/README.md index 77997f98..7105e902 100644 --- a/examples/server/README.md +++ b/examples/server/README.md @@ -77,34 +77,31 @@ You need to have [Node.js](https://nodejs.org/en) installed. ```bash mkdir llama-client cd llama-client -npm init -npm install axios ``` Create a index.js file and put inside this: ```javascript -const axios = require("axios"); - const prompt = `Building a website can be done in 10 simple steps:`; async function Test() { - let result = await axios.post("http://127.0.0.1:8080/completion", { - prompt, - n_predict: 512, - }); - - // the response is received until completion finish - console.log(result.data.content); + let response = await fetch("http://127.0.0.1:8080/completion", { + method: 'POST', + body: JSON.stringify({ + prompt, + n_predict: 512, + }) + }) + console.log((await response.json()).content) } -Test(); +Test() ``` And run it: ```bash -node . +node index.js ``` ## API Endpoints