Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc: prefer docker-compose than docker compose, add pop query bash script #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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.
Expand All @@ -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
Expand Down
23 changes: 23 additions & 0 deletions scripts/pop.sh
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'