mirror of
https://github.com/kmein/niveum
synced 2026-03-30 09:11:10 +02:00
feat(kleim): add gpt, do not remove newlines
This commit is contained in:
15
packages/gpt.nix
Normal file
15
packages/gpt.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
curl,
|
||||
writers,
|
||||
jq,
|
||||
apiKeyCommand ? "pass api-keys/openai.com",
|
||||
model ? "gpt-3.5-turbo",
|
||||
}:
|
||||
writers.writeDashBin "gpt" ''
|
||||
json=$(jq --slurp --raw-input '{model:"${model}", messages: [{role: "user", content: .}]}')
|
||||
${curl}/bin/curl -sSL https://api.openai.com/v1/chat/completions \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $(pass api-keys/openai.com)" \
|
||||
-d "$json" \
|
||||
| ${jq}/bin/jq -r '.choices[] | .message.content'
|
||||
''
|
||||
Reference in New Issue
Block a user