Skip to content

Commit 6c277ea

Browse files
committed
update api like OpenAI
1 parent 58f8ae9 commit 6c277ea

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

examples/server/api_like_OAI.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99

1010
app = Flask(__name__)
11+
slot_id = -1
1112

1213
parser = argparse.ArgumentParser(description="An example of using server.cpp with a similar API to OAI. It must be used together with server.cpp.")
1314
parser.add_argument("--chat-prompt", type=str, help="the top prompt in chat completions(default: 'A chat between a curious user and an artificial intelligence assistant. The assistant follows the given rules no matter what.\\n')", default='A chat between a curious user and an artificial intelligence assistant. The assistant follows the given rules no matter what.\\n')
@@ -77,7 +78,8 @@ def make_postData(body, chat=False, stream=False):
7778
if(is_present(body, "stop")): postData["stop"] += body["stop"]
7879
postData["n_keep"] = -1
7980
postData["stream"] = stream
80-
81+
postData["cache_prompt"] = True
82+
postData["slot_id"] = slot_id
8183
return postData
8284

8385
def make_resData(data, chat=False, promptToken=[]):
@@ -128,6 +130,7 @@ def make_resData_stream(data, chat=False, time_now = 0, start=False):
128130
}
129131
]
130132
}
133+
slot_id = data["slot_id"]
131134
if (chat):
132135
if (start):
133136
resData["choices"][0]["delta"] = {

examples/server/server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "build-info.h"
44
#include "grammar-parser.h"
55

6-
// #define SERVER_MULTIMODAL_SUPPORT
6+
//#define SERVER_MULTIMODAL_SUPPORT
77

88
#ifdef SERVER_MULTIMODAL_SUPPORT
99
#include "../llava/clip.h"

0 commit comments

Comments
 (0)