fix whitespace, edit README.md

This commit is contained in:
jwj7140 2023-06-30 00:03:02 +09:00
parent a4149aa0c8
commit d7435fe320
2 changed files with 17 additions and 1 deletions

View file

@ -190,3 +190,19 @@ Run with bash:
```sh ```sh
bash chat.sh bash chat.sh
``` ```
### API like OAI
API example using Python Flask: [api_like_OAI.py](api_like_OAI.py)
This example must be used with server.cpp
```sh
python api_like_OAI.py
```
After running the API server, you can use it in Python by setting the API base URL.
```python
openai.api_base = "http://<Your api-server IP>:port"
```
Then you can utilize llama.cpp as an OpenAI's **chat.completion** or **text_completion** API

View file

@ -70,7 +70,7 @@ def make_postData(body, chat=False, stream=False):
if(is_present(body, "logit_bias")): postData["logit_bias"] = [[int(token), body["logit_bias"][token]] for token in body["logit_bias"].keys()] if(is_present(body, "logit_bias")): postData["logit_bias"] = [[int(token), body["logit_bias"][token]] for token in body["logit_bias"].keys()]
postData["stop"] = [args.stop] postData["stop"] = [args.stop]
if(is_present(body, "stop")): postData["stop"] += body["stop"] if(is_present(body, "stop")): postData["stop"] += body["stop"]
postData["stream"] = stream postData["stream"] = stream
return postData return postData