Skip to content

Commit 26f2396

Browse files
committed
add pop querier bash script and prefere usage of docker-compose than docker compose which isn-t available everywhere yet
1 parent a2e30ff commit 26f2396

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ git clone https://github.com/centreonlabs/plugin-output-processing.git
6060

6161
cd plugin-output-processing
6262

63-
docker compose --profile ollama up
63+
docker-compose --profile ollama up
6464
```
6565

6666
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
8282
```bash
8383
export OPENAI_API_KEY=...
8484

85-
docker compose up
85+
docker-compose up
8686
```
8787

8888
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
9292
> If you want to use the OpenAI API, you must unset the `OLLAMA_HOST` if it exists and can reach an ollama instance.
9393
9494
> [!CAUTHION]
95-
> If you want to switch between providers (OpenAI to Ollama or vice versa), you must change the configuration file or removing it.
95+
> If you want to switch between providers (OpenAI to Ollama or vice versa), you must change the configuration file or remove it.
9696
9797
```bash
9898
# Example to switch from OpenAI to Ollama
9999

100-
docker compose down
100+
docker-compose down
101101

102102
docker volume rm pop_pop
103103

104104
# We need to recreate the network because ollama will start first.
105-
docker compose --profile ollama up --force-recreate
105+
docker-compose --profile ollama up --force-recreate
106106
```
107107

108108
### Running the API locally

scripts/pop.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# This script prompts the user to input plugin output text, URL encodes the input,
4+
# and sends it to a specified API endpoint for explanation. The response from the
5+
# API is then formatted and displayed to the user.
6+
7+
# Prompt the user to input text
8+
read -p "Enter plugin output you want to be explained: " input_text
9+
10+
echo
11+
echo "----------"
12+
echo
13+
14+
# URL encode the input text
15+
encoded_text=$(echo -n "$input_text" | jq -s -R -r @uri)
16+
17+
# Define the API endpoint, replacing YOUR_API_ENDPOINT with the actual endpoint
18+
api_endpoint="http://127.0.0.1:8000/explain"
19+
20+
# Make the GET request
21+
response=$(curl -s "${api_endpoint}?type=service&output=${encoded_text}")
22+
23+
# replace return carriage and display the response
24+
echo $response | sed 's/\\n/\n/g'

0 commit comments

Comments
 (0)