From 01c1fffe0ac51ad7a0ade29c4c4f6fed4394dd44 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 17 Apr 2023 15:59:58 +0200 Subject: reaktor2 bing: more timeout, footnotes --- krebs/2configs/reaktor2.nix | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'krebs') 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 ''; }; }; -- cgit v1.2.3