This commit is contained in:
Yazan Agha-Schrader 2025-01-26 16:26:40 +00:00 committed by GitHub
commit 4b7260f26b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 user 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[1mAssistant\033[0m"
request_oai
done