mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-24 10:24:35 +00:00
examples : skip unnecessary external lib in server README.md how-to (#2804)
This commit is contained in:
parent
232caf3c15
commit
bae5c5f679
@ -77,34 +77,31 @@ You need to have [Node.js](https://nodejs.org/en) installed.
|
|||||||
```bash
|
```bash
|
||||||
mkdir llama-client
|
mkdir llama-client
|
||||||
cd llama-client
|
cd llama-client
|
||||||
npm init
|
|
||||||
npm install axios
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Create a index.js file and put inside this:
|
Create a index.js file and put inside this:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const axios = require("axios");
|
|
||||||
|
|
||||||
const prompt = `Building a website can be done in 10 simple steps:`;
|
const prompt = `Building a website can be done in 10 simple steps:`;
|
||||||
|
|
||||||
async function Test() {
|
async function Test() {
|
||||||
let result = await axios.post("http://127.0.0.1:8080/completion", {
|
let response = await fetch("http://127.0.0.1:8080/completion", {
|
||||||
prompt,
|
method: 'POST',
|
||||||
n_predict: 512,
|
body: JSON.stringify({
|
||||||
});
|
prompt,
|
||||||
|
n_predict: 512,
|
||||||
// the response is received until completion finish
|
})
|
||||||
console.log(result.data.content);
|
})
|
||||||
|
console.log((await response.json()).content)
|
||||||
}
|
}
|
||||||
|
|
||||||
Test();
|
Test()
|
||||||
```
|
```
|
||||||
|
|
||||||
And run it:
|
And run it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
node .
|
node index.js
|
||||||
```
|
```
|
||||||
|
|
||||||
## API Endpoints
|
## API Endpoints
|
||||||
|
Loading…
Reference in New Issue
Block a user