From c0d083ca25793ff00549850912b23bb49b9f4744 Mon Sep 17 00:00:00 2001 From: Yazan Agha-Schrader Date: Sat, 2 Dec 2023 17:36:22 +0100 Subject: [PATCH 1/4] Create api_like_OAI.sh shell script with a simple example utilizing the new oai api like compatibility --- examples/server/api_like_OAI.sh | 52 +++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 examples/server/api_like_OAI.sh diff --git a/examples/server/api_like_OAI.sh b/examples/server/api_like_OAI.sh new file mode 100644 index 000000000..12834168c --- /dev/null +++ b/examples/server/api_like_OAI.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +API_URL="http://localhost:8080/v1/chat/completions" +AUTH_TOKEN="Bearer no-key" + +request_oai(){ + curl -s --no-buffer "$API_URL" \ + -H "Content-Type: application/json" \ + -H "Authorization: $AUTH_TOKEN" \ + -d '{ + "model": "gpt-3.5-turbo", + "max_tokens": 64, + "temperature": 1, + "top_k": 0, + "top_p": 1, + "min_p": 0.5, + "stream": true, + "repeat_penalty": 1, + "repeat_last_n": 0, + "presence_penalty": 0, + "frequency_penalty": 0, + "ignore_eos": false, + "n_probs": 0, + "seed": -1, + "messages": [ + { + "role": "system", + "content": "You are an AI assistant. Your top priority is to fulfill the requests of the by helping them with their needs." + }, + { + "role": "user", + "content": "'"$USER_INPUT"'" + } + ] + }' | \ + while IFS= read -r LINE; do + if [[ $LINE = data:* ]]; then + CONTENT="$(echo "${LINE:5}" | jq -r '.choices[].delta.content // empty')" + printf "%s" "${CONTENT}" + fi + done + echo + echo +} + +while true; do + echo -e "\033[1;94mUser\033[0m" + read -r USER_INPUT + echo + echo -e "\033[1mAssistent\033[0m" + request_oai +done From fd3baee14e8aa332f1f25c735fdffadde133bf1b Mon Sep 17 00:00:00 2001 From: Yazan Agha-Schrader Date: Sun, 3 Dec 2023 14:16:41 +0100 Subject: [PATCH 2/4] Update and rename api_like_OAI.sh to api-like-OAI.sh --- examples/server/{api_like_OAI.sh => api-like-OAI.sh} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename examples/server/{api_like_OAI.sh => api-like-OAI.sh} (94%) diff --git a/examples/server/api_like_OAI.sh b/examples/server/api-like-OAI.sh similarity index 94% rename from examples/server/api_like_OAI.sh rename to examples/server/api-like-OAI.sh index 12834168c..3af0dda45 100644 --- a/examples/server/api_like_OAI.sh +++ b/examples/server/api-like-OAI.sh @@ -25,7 +25,7 @@ request_oai(){ "messages": [ { "role": "system", - "content": "You are an AI assistant. Your top priority is to fulfill the requests of the by helping them with their needs." + "content": "You are an AI assistant. Your top priority is to fulfill the requests of the user by helping them with their needs." }, { "role": "user", From 311f3b16dceeb511566c69a844f684d2cf01e9ba Mon Sep 17 00:00:00 2001 From: Yazan Agha-Schrader Date: Tue, 5 Dec 2023 13:06:29 +0100 Subject: [PATCH 3/4] Update examples/server/api-like-OAI.sh Co-authored-by: Georgi Gerganov --- examples/server/api-like-OAI.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/server/api-like-OAI.sh b/examples/server/api-like-OAI.sh index 3af0dda45..75c97e099 100644 --- a/examples/server/api-like-OAI.sh +++ b/examples/server/api-like-OAI.sh @@ -47,6 +47,6 @@ while true; do echo -e "\033[1;94mUser\033[0m" read -r USER_INPUT echo - echo -e "\033[1mAssistent\033[0m" + echo -e "\033[1mAssistant\033[0m" request_oai done From ddd99712361da8912606c881274b34d81c4638c7 Mon Sep 17 00:00:00 2001 From: Yazan Agha-Schrader Date: Tue, 5 Dec 2023 13:09:18 +0100 Subject: [PATCH 4/4] Rename api-like-OAI.sh to chat-OAI.sh --- examples/server/{api-like-OAI.sh => chat-OAI.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/server/{api-like-OAI.sh => chat-OAI.sh} (100%) diff --git a/examples/server/api-like-OAI.sh b/examples/server/chat-OAI.sh similarity index 100% rename from examples/server/api-like-OAI.sh rename to examples/server/chat-OAI.sh