diff --git a/README.md b/README.md index ff34c66..314a1b6 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ git clone https://github.com/centreonlabs/plugin-output-processing.git cd plugin-output-processing -docker compose --profile ollama up +docker-compose --profile ollama up ``` After the container is up, you can try the API at `http://localhost:8000/docs`. @@ -82,7 +82,7 @@ This method requires an [OpenAI API key](https://help.openai.com/en/articles/493 ```bash export OPENAI_API_KEY=... -docker compose up +docker-compose up ``` After the container is up, you can try the API the same way as the previous section. @@ -92,17 +92,17 @@ After the container is up, you can try the API the same way as the previous sect > If you want to use the OpenAI API, you must unset the `OLLAMA_HOST` if it exists and can reach an ollama instance. > [!CAUTHION] -> If you want to switch between providers (OpenAI to Ollama or vice versa), you must change the configuration file or removing it. +> If you want to switch between providers (OpenAI to Ollama or vice versa), you must change the configuration file or remove it. ```bash # Example to switch from OpenAI to Ollama -docker compose down +docker-compose down docker volume rm pop_pop # We need to recreate the network because ollama will start first. -docker compose --profile ollama up --force-recreate +docker-compose --profile ollama up --force-recreate ``` ### Running the API locally diff --git a/scripts/pop.sh b/scripts/pop.sh new file mode 100755 index 0000000..1409bf3 --- /dev/null +++ b/scripts/pop.sh @@ -0,0 +1,24 @@ +#!/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) + +# Define the API endpoint, replacing YOUR_API_ENDPOINT with the actual endpoint +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'