diff options
author | lassulus <git@lassul.us> | 2023-04-17 15:59:58 +0200 |
---|---|---|
committer | lassulus <git@lassul.us> | 2023-04-17 15:59:58 +0200 |
commit | 01c1fffe0ac51ad7a0ade29c4c4f6fed4394dd44 (patch) | |
tree | c4fdad4c827b3ca4c59cb8f4c7495d78a422aa41 /krebs/2configs | |
parent | d8ca1ceb9d9f91b34312ca7f6645c97560907949 (diff) |
reaktor2 bing: more timeout, footnotes
Diffstat (limited to 'krebs/2configs')
-rw-r--r-- | krebs/2configs/reaktor2.nix | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix index 032932013..8e2e5d9b8 100644 --- a/krebs/2configs/reaktor2.nix +++ b/krebs/2configs/reaktor2.nix @@ -55,7 +55,7 @@ let pattern = "!bing (.*)$"; activate = "match"; arguments = [1]; - timeoutSec = 42; + timeoutSec = 1337; command = { filename = pkgs.writeDash "bing" '' set -efu @@ -64,10 +64,21 @@ let pkgs.curl pkgs.jq ]} - printf '%s' "$*" | - curl -SsG http://bing-gpt.r/api/chat --data-urlencode 'prompt@-' | - jq -r '.item.messages[1].text' | - echo "$_from: $(cat)" + response=$(printf '%s' "$*" | + curl -SsG http://bing-gpt.r/api/chat --data-urlencode 'prompt@-' + ) + if [ "$?" -ne 0 ]; then + printf '%s' "$response" | + curl -Ss http://p.r --data-binary @- | + tail -1 + else + printf '%s' "$response" | + jq -r '.item.messages[1].text' | + echo "$_from: $(cat)" + + printf '%s' "$response" | + jq -r '[.item.messages[1].sourceAttributions[].seeMoreUrl] | to_entries[] | "[\(.key)]: \(.value)"' + fi ''; }; }; |