From d7435fe320ad177f1897f40fcb25bfff8852f6ba Mon Sep 17 00:00:00 2001 From: jwj7140 Date: Fri, 30 Jun 2023 00:03:02 +0900 Subject: [PATCH] fix whitespace, edit README.md --- examples/server/README.md | 16 ++++++++++++++++ examples/server/api_like_OAI.py | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/examples/server/README.md b/examples/server/README.md index fa95c0044..fdd973e23 100644 --- a/examples/server/README.md +++ b/examples/server/README.md @@ -190,3 +190,19 @@ Run with bash: ```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://:port" +``` + +Then you can utilize llama.cpp as an OpenAI's **chat.completion** or **text_completion** API \ No newline at end of file diff --git a/examples/server/api_like_OAI.py b/examples/server/api_like_OAI.py index 02a846320..93c9bb49d 100755 --- a/examples/server/api_like_OAI.py +++ b/examples/server/api_like_OAI.py @@ -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()] postData["stop"] = [args.stop] if(is_present(body, "stop")): postData["stop"] += body["stop"] - + postData["stream"] = stream return postData