-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into enhanced-prompt
- Loading branch information
Showing
2 changed files
with
28 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# This script prompts the user to input plugin output text, URL encodes the input, | ||
# and sends it to a specified API endpoint for explanation. The response from the | ||
# API is then formatted and displayed to the user. | ||
|
||
# Prompt the user to input text | ||
read -p "Enter plugin output you want to be explained: " input_text | ||
|
||
echo | ||
echo "----------" | ||
echo | ||
|
||
# URL encode the input text | ||
encoded_text=$(echo -n "$input_text" | jq -s -R -r @uri) | ||
|
||
api_endpoint="http://127.0.0.1:8000/explain" | ||
|
||
# Make the GET request | ||
response=$(curl -s "${api_endpoint}?type=service&output=${encoded_text}") | ||
|
||
# replace return carriage and display the response | ||
echo $response | sed 's/\\n/\n/g' |