-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmistral.sh
29 lines (25 loc) · 817 Bytes
/
mistral.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# Check if both model and content are provided as arguments
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <tiny/small/medium> <blablabla>"
exit 1
fi
MODEL="$1"
CONTENT="$2"
ACCESS_TOKEN="Paste your API key here"
# Make API call and store the output in a variable
OUTPUT=$(curl -s --location "https://api.mistral.ai/v1/chat/completions" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--data '{
"model": "'"mistral-$MODEL"'",
"messages": [
{
"role": "user",
"content": "'"$CONTENT"'"
}
]
}' | jq -r '.choices[0].message.content')
# Print a formatted message with the output
echo -e "\033[1;32m $OUTPUT \033[0m"