Skip to content

Commit

Permalink
add pop querier bash script and prefere usage of docker-compose than …
Browse files Browse the repository at this point in the history
…docker compose which isn-t available everywhere yet
  • Loading branch information
Nohzoh committed Nov 13, 2024
1 parent a2e30ff commit 26f2396
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
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
24 changes: 24 additions & 0 deletions scripts/pop.sh
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit 26f2396

Please sign in to comment.