Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,31 @@ Here are some example queries you can try:
- **"Can I order a coffee and a cookie?"**
- *Expected Response:*
*"Your order for a coffee and a chocolate chip cookie has been saved. The total is $5.00. Would you like anything else?"*

## Try metrics

Helidon provides `MetricsChatModelListener` which generates metrics that follow the [OpenTelemetry Semantic Conventions for GenAI Metrics v1.36.0](https://github.com/open-telemetry/semantic-conventions/blob/v1.36.0/docs/gen-ai/gen-ai-metrics.md). This is done out-of-box for Chat API calls. To view the captured metrics use following:

```shell
# Prometheus Format
curl -s -X GET http://localhost:8080/metrics
...
# HELP gen_ai_client_token_usage_token Measures number of input and output tokens used
# TYPE gen_ai_client_token_usage_token histogram
gen_ai_client_token_usage_token{gen_ai_operation_name="chat",gen_ai_request_model="gpt-4o-mini",gen_ai_response_model="gpt-4o-mini-2024-07-18",gen_ai_token_type="output",scope="vendor",quantile="0.5",} 71.0
...
gen_ai_client_token_usage_token{gen_ai_operation_name="chat",gen_ai_request_model="gpt-4o-mini",gen_ai_response_model="gpt-4o-mini-2024-07-18",gen_ai_token_type="input",scope="vendor",quantile="0.5",} 156.0
...
# HELP gen_ai_client_token_usage_token_max Measures number of input and output tokens used
# TYPE gen_ai_client_token_usage_token_max gauge
gen_ai_client_token_usage_token_max{gen_ai_operation_name="chat",gen_ai_request_model="gpt-4o-mini",gen_ai_response_model="gpt-4o-mini-2024-07-18",gen_ai_token_type="output",scope="vendor",} 71.0
gen_ai_client_token_usage_token_max{gen_ai_operation_name="chat",gen_ai_request_model="gpt-4o-mini",gen_ai_response_model="gpt-4o-mini-2024-07-18",gen_ai_token_type="input",scope="vendor",} 156.0
....
# HELP gen_ai_client_operation_duration_seconds_max GenAI operation duration
# TYPE gen_ai_client_operation_duration_seconds_max gauge
gen_ai_client_operation_duration_seconds_max{error_type="",gen_ai_operation_name="chat",gen_ai_request_model="gpt-4o-mini",gen_ai_response_model="gpt-4o-mini-2024-07-18",scope="vendor",} 2.0
# HELP gen_ai_client_operation_duration_seconds GenAI operation duration
# TYPE gen_ai_client_operation_duration_seconds histogram
gen_ai_client_operation_duration_seconds{error_type="",gen_ai_operation_name="chat",gen_ai_request_model="gpt-4o-mini",gen_ai_response_model="gpt-4o-mini-2024-07-18",scope="vendor",quantile="0.5",} 2.0
...
```
10 changes: 0 additions & 10 deletions examples/integrations/langchain4j/coffee-shop-assistant-mp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@
<mainClass>io.helidon.Main</mainClass>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-embeddings-all-minilm-l6-v2</artifactId>
<version>${version.lib.langchain4j}</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.helidon.integrations.langchain4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ langchain4j.open-ai.chat-model.model-name=gpt-4o-mini
langchain4j.rag.embedding-store-content-retriever.enabled=true
langchain4j.rag.embedding-store-content-retriever.max-results=10
langchain4j.rag.embedding-store-content-retriever.min-score=0.6
langchain4j.rag.embedding-store-content-retriever.embedding-store=EmbeddingStore
langchain4j.rag.embedding-store-content-retriever.embedding-store.service-registry.named=EmbeddingStore

app.menu-items=data/menu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# **Coffee Shop Assistant (Helidon SE Version)**

This is a **demo application** showcasing the **Helidon SE integration with LangChain4J**. It demonstrates how to build an **AI-powered coffee shop assistant** using **Helidon Inject**, Ollama models, and Coherence LangChain4J integrations.

NOTE: LangChain4J integration is a preview feature. The APIs shown here are subject to change. These APIs will be finalized in a future release of Helidon.

## **Features**

- Integration with **OpenAI chat models**.
- Utilization of **embedding models**, **embedding store**, **ingestor**, and **content retriever**.
- **Helidon Inject** for dependency injection.
- **Embedding store initialization** from a JSON file.
- Integration with **Coherence Embedding Store**
- Support for **callback functions** to enhance interactions.

## **Build the Application**

To build the application, run:

```shell
mvn clean package
```

## **Run the Application**

Execute the following command to start the application:

```shell
java -Dcoherence.wka=127.0.0.1 -jar target/helidon-examples-integrations-langchain4j-coffee-shop-assistant-se-coherence.jar
```

Once running, you can interact with the assistant via your browser.

Example:

```
http://localhost:8080/chat?question="What can you offer today?"
```

## Sample Questions and Expected Responses

Here are some example queries you can try:

### Menu and Recommendations

- **"What hot drinks do you have?"**
- *Expected Response:* A list of **hot drinks** such as **Latte, Cappuccino, Espresso, and Hot Chocolate**.

- **"I'm looking for something sweet. What do you recommend?"**
- *Expected Response:* Suggestions like **Caramel Frappuccino, Blueberry Muffin, Chocolate Chip Cookie, and Hot Chocolate**.

- **"What drinks can I get with caramel?"**
- *Expected Response:* Options like **Caramel Frappuccino** and **Latte with caramel syrup add-on**.

### Dietary Preferences

- **"Do you have any vegan options?"**
- *Expected Response:* Items like **Avocado Toast, Iced Matcha Latte (with non-dairy milk), and Blueberry Muffin (if applicable)**.

### Orders and Availability

- **"Do you have any breakfast items?"**
- *Expected Response:* Options such as **Avocado Toast, Blueberry Muffin, and Bagel with Cream Cheese**.

- **"Can I order a coffee and a cookie?"**
- *Expected Response:*
*"Your order for a coffee and a chocolate chip cookie has been saved. The total is $5.00. Would you like anything else?"*
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
[
{
"name": "Latte",
"description": "A rich espresso drink with steamed milk.",
"category": "Drink",
"price": 4.5,
"tags": [
"Hot",
"Customizable",
"Classic"
],
"addOns": [
"Oat milk",
"Soy milk",
"Extra shot",
"Caramel syrup"
]
},
{
"name": "Cappuccino",
"description": "Espresso topped with a thick layer of frothy milk.",
"category": "Drink",
"price": 4.0,
"tags": [
"Hot",
"Foamy",
"Classic"
],
"addOns": [
"Vanilla syrup",
"Extra shot"
]
},
{
"name": "Espresso",
"description": "A strong shot of coffee for a quick energy boost.",
"category": "Drink",
"price": 3.0,
"tags": [
"Hot",
"Classic",
"Bold"
],
"addOns": [
"Extra shot"
]
},
{
"name": "Iced Matcha Latte",
"description": "Chilled matcha green tea with milk.",
"category": "Drink",
"price": 5.0,
"tags": [
"Cold",
"Vegan",
"Trendy"
],
"addOns": [
"Oat milk",
"Almond milk",
"Extra matcha"
]
},
{
"name": "Avocado Toast",
"description": "Toasted bread topped with mashed avocado and seasonings.",
"category": "Food",
"price": 6.5,
"tags": [
"Healthy",
"Vegan",
"Breakfast"
],
"addOns": [
"Egg",
"Feta cheese",
"Hot sauce"
]
},
{
"name": "Blueberry Muffin",
"description": "A soft muffin bursting with blueberries.",
"category": "Food",
"price": 2.75,
"tags": [
"Breakfast",
"Sweet",
"Vegetarian"
],
"addOns": [
"Warm up"
]
},
{
"name": "Bagel with Cream Cheese",
"description": "A freshly baked bagel served with creamy cheese spread.",
"category": "Food",
"price": 3.5,
"tags": [
"Breakfast",
"Savory",
"Vegetarian"
],
"addOns": [
"Butter",
"Jam"
]
},
{
"name": "Caramel Frappuccino",
"description": "A blended coffee drink with caramel drizzle and whipped cream.",
"category": "Drink",
"price": 5.5,
"tags": [
"Cold",
"Sweet",
"Indulgent"
],
"addOns": [
"Extra caramel",
"Whipped cream"
]
},
{
"name": "Chocolate Chip Cookie",
"description": "A large, soft-baked cookie loaded with chocolate chips.",
"category": "Food",
"price": 2.0,
"tags": [
"Snack",
"Sweet",
"Vegetarian"
],
"addOns": [
"Warm up"
]
},
{
"name": "Hot Chocolate",
"description": "A creamy hot chocolate drink topped with whipped cream.",
"category": "Drink",
"price": 3.75,
"tags": [
"Hot",
"Sweet",
"Comforting"
],
"addOns": [
"Extra whipped cream",
"Caramel drizzle"
]
}
]
Loading