Skip to content

Commit

Permalink
Merge pull request #499 from jmartisk/readmes
Browse files Browse the repository at this point in the history
Add READMEs to all samples
  • Loading branch information
jmartisk authored Apr 24, 2024
2 parents 2de36ca + 2b36c0c commit 812982c
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 5 deletions.
30 changes: 30 additions & 0 deletions samples/chatbot-easy-rag/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Chatbot example with Easy RAG

This example demonstrates how to create a simple chatbot with RAG using
`quarkus-langchain4j` and specifically the Easy RAG extension.
For more information about Easy RAG, refer to the file
`docs/modules/ROOT/pages/easy-rag.adoc`.

## Running the example

A prerequisite to running this example is to provide your OpenAI API key.

```
export QUARKUS_LANGCHAIN4J_OPENAI_API_KEY=<your-openai-api-key>
```

Then, simply run the project in Dev mode:

```
mvn quarkus:dev
```

## Using the example


Open your browser and navigate to http://localhost:8080. Click the red robot
in the bottom right corner to open the chat window.

The chatbot is a conversational agent that uses information from the files
in `src/main/resources/catalog` to answer your questions about banking
products. More information about how it works is shown on the webpage.
1 change: 0 additions & 1 deletion samples/chatbot-easy-rag/README.txt

This file was deleted.

26 changes: 26 additions & 0 deletions samples/chatbot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Chatbot example

This example demonstrates how to create a simple chatbot with RAG using `quarkus-langchain4j`.

## Running the example

A prerequisite to running this example is to provide your OpenAI API key.

```
export QUARKUS_LANGCHAIN4J_OPENAI_API_KEY=<your-openai-api-key>
```

Then, simply run the project in Dev mode:

```
mvn quarkus:dev
```

## Using the example

Open your browser and navigate to http://localhost:8080. Click the red robot
in the bottom right corner to open the chat window.

The chatbot is a conversational agent that uses information from the files
in `src/main/resources/catalog` to answer your questions about banking
products. More information about how it works is shown on the webpage.
40 changes: 40 additions & 0 deletions samples/cli-translator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# CLI Translator example

This example demonstrates how to create a CLI-based translator application
powered by an LLM.

## Preparing to run the example

A prerequisite to running this example is to provide your OpenAI API key.

```
export QUARKUS_LANGCHAIN4J_OPENAI_API_KEY=<your-openai-api-key>
```

## Using the example in interactive mode

Compile the project and run it:

```
mvn package
java -jar target/quarkus-app/quarkus-run.jar
```

Optionally, specify a target language for the translation using `-l`, this
defaults to English. Then, simply write something in your language and
always leave an empty line to get the translation.

## Using the example in command mode

You can also specify a file to translate by appending it as the program's argument,
for example:

```
mvn package
java -jar target/quarkus-app/quarkus-run.jar examples/french.txt
```

This also works with Dev mode:
```
mvn quarkus:dev -Dquarkus.args="examples/french.txt"
```
26 changes: 22 additions & 4 deletions samples/csv-chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@

![Movie Muse](moviemuse.png)

Set your OpenAI API key into the `QUARKUS_LANGCHAIN4J_OPENAI_API_KEY`
environment variable. Then, run the example by executing `mvn quarkus:dev`
and open `localhost:8080` in your browser and start chatting.
This example demonstrates how to create a chatbot with RAG using
`quarkus-langchain4j`. This chatbot internally uses LLM-generated SQL
queries to retrieve the relevant information from a PostgreSQL database.

## Running the example

A prerequisite to running this example is to provide your OpenAI API key.

```
export QUARKUS_LANGCHAIN4J_OPENAI_API_KEY=<your-openai-api-key>
```

Then, simply run the project in Dev mode:

```
mvn quarkus:dev
```

## Using the example

Open your browser and navigate to http://localhost:8080. Click the orange robot
in the bottom right corner to open the chat window.

The chatbot uses a SQL database with information about movies with their
basic metadata (the database is populated with data from
Expand All @@ -13,4 +32,3 @@ LLM is used to generate SQL queries necessary for answering your question.
Check the application's log, the SQL queries and the retrieved data will be
printed there.


44 changes: 44 additions & 0 deletions samples/email-a-poem/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# AI Service example with Tools that can write a poem and send it by email

This example demonstrates how to create a chatbot with RAG using
`quarkus-langchain4j`. This chatbot internally uses LLM-generated SQL
queries to retrieve the relevant information from a PostgreSQL database.

## Running the example

A prerequisite to running this example is to provide your OpenAI API key.

```
export QUARKUS_LANGCHAIN4J_OPENAI_API_KEY=<your-openai-api-key>
```

To allow the application to send emails, start a mock SMTP server (replace
Podman with your own container runtime):

```
podman run -p 8025:8025 -p 1025:1025 docker.io/mailhog/mailhog
```

Then, simply run the project in Dev mode:

```
mvn quarkus:dev
```

## Using the example

Open the UI of the mock SMTP server at http://localhost:8025. This is where any
emails sent by the robot will appear.

To have the robot write a poem and send it to `[email protected]` (the
actual address doesn't matter, for any address it will simply appear in the
SMTP server's UI), execute:

```
curl http://localhost:8080/email-me-a-poem
```

If you don't have curl or a similar tool, simply opening the URL in your web
browser will work too. After this is done, open the SMTP server's UI and you
will see the email with a poem about Quarkus.

Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ quarkus.langchain4j.openai.timeout=60s
quarkus.langchain4j.openai.log-requests=true
quarkus.langchain4j.openai.log-responses=true

quarkus.mailer.from[email protected]
quarkus.mailer.port=1025
quarkus.mailer.host=localhost
%dev.quarkus.mailer.mock=false
27 changes: 27 additions & 0 deletions samples/review-triage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Review triage example

This example demonstrates how to a sentiment-analyzing AI service
with `quarkus-langchain4j`.

## Running the example

A prerequisite to running this example is to provide your OpenAI API key.

```
export QUARKUS_LANGCHAIN4J_OPENAI_API_KEY=<your-openai-api-key>
```

Then, simply run the project in Dev mode:

```
mvn quarkus:dev
```

## Using the example

Open your browser and navigate to http://localhost:8080. The application
acts as a bank's robot that accepts new reviews written by clients, analyzes
their sentiment and thinks up an appropriate response to the client. Simply
write something positive (`Your services are great.`) or negative (`You are
thieves!`) into the form and click Submit.

0 comments on commit 812982c

Please sign in to comment.