-
-
Save sroecker/d92a080601ed2863aa0f285a08610eef to your computer and use it in GitHub Desktop.
Revisions
-
sroecker revised this gist
Nov 15, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ #!/usr/bin/env bash # based off of https://gist.github.com/rauchg/c5f0b1dc245ad95c593de8336aa382ac?permalink_comment_id=4842642#gistcomment-4842642 # further adapted from https://gist.github.com/algal/5e815ffd371d57d3a6a37056db1bd281 if [ "$#" -eq 0 ]; then echo "Usage: $(basename $0) promt_to_send_to_perplexity" echo "" -
sroecker revised this gist
Nov 15, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,6 @@ if [ "$#" -eq 0 ]; then echo " Requirements: PERPLEXITY_API, defined; jq and curl, installed; bash, version 3 or higher." exit 1 fi function p() { local json_request @@ -32,7 +31,8 @@ function p() { --data "$json_request") #echo $json_response # uncomment to debug content=$(echo "$json_response" | jq '.choices[0].message.content') echo -e $content echo "Citations:" echo "$json_response" | jq '.citations[]' | tr -d '"' | nl } -
sroecker revised this gist
Nov 15, 2024 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,21 +6,22 @@ if [ "$#" -eq 0 ]; then echo " Requirements: PERPLEXITY_API, defined; jq and curl, installed; bash, version 3 or higher." exit 1 fi #!/usr/bin/env bash function p() { local json_request json_request=$(jq -n \ --arg content "$*" \ '{ "model": "llama-3.1-sonar-small-128k-online", "messages": [ { "role": "system", "content": "Be precise and concise." }, { "role": "user", "content": $content } ], "stream": false }') # echo $json_request # uncomment to debug local json_response json_response=$(curl --silent \ --request POST \ @@ -29,8 +30,10 @@ function p() { --header "authorization: Bearer $PERPLEXITY_API" \ --header 'content-type: application/json' \ --data "$json_request") #echo $json_response # uncomment to debug echo "$json_response" | jq '.choices[0].message.content' echo "Citations:" echo "$json_response" | jq '.citations[]' | tr -d '"' | nl } p "$*" -
algal created this gist
Jan 22, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ #!/usr/bin/env bash # based off of https://gist.github.com/rauchg/c5f0b1dc245ad95c593de8336aa382ac?permalink_comment_id=4842642#gistcomment-4842642 if [ "$#" -eq 0 ]; then echo "Usage: $(basename $0) promt_to_send_to_perplexity" echo "" echo " Requirements: PERPLEXITY_API, defined; jq and curl, installed; bash, version 3 or higher." exit 1 fi function p() { local json_request json_request=$(jq -n \ --arg content "$*" \ '{ "model": "pplx-7b-online", "messages": [ { "role": "system", "content": "Be precise and concise." }, { "role": "user", "content": $content } ], "stream": false }') # echo $json_request # uncomment to debug local json_response json_response=$(curl --silent \ --request POST \ --url https://api.perplexity.ai/chat/completions \ --header 'accept: application/json' \ --header "authorization: Bearer $PERPLEXITY_API" \ --header 'content-type: application/json' \ --data "$json_request") # echo $json_response # uncomment to debug echo "$json_response" | jq --raw-output .choices[0].message.content } p "$*"