Skip to content

Commit

Permalink
Replace the SQL chatbot Data Ingestion with Camel Route & fix the GPT…
Browse files Browse the repository at this point in the history
… default model name in the doc
  • Loading branch information
zbendhiba committed Jan 3, 2025
1 parent c1ac62f commit c020ad0
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 50 deletions.
26 changes: 22 additions & 4 deletions samples/sql-chatbot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>3.15.2</quarkus.platform.version>
<quarkus.platform.version>3.17.5</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.2.5</surefire-plugin.version>
<camel.quarkus.version>3.17.0</camel.quarkus.version>
<quarkus-langchain4j.version>0.23.0.CR2</quarkus-langchain4j.version>
</properties>

Expand Down Expand Up @@ -55,11 +56,28 @@
<artifactId>quarkus-langchain4j-openai</artifactId>
<version>${quarkus-langchain4j.version}</version>
</dependency>

<!-- Data Ingestion with Apache Camel -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-csv</artifactId>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-file</artifactId>
<version>${camel.quarkus.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jpa</artifactId>
<version>${camel.quarkus.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-csv</artifactId>
<version>${camel.quarkus.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bindy</artifactId>
<version>${camel.quarkus.version}</version>
</dependency>


<!-- UI -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.quarkiverse.langchain4j.sample.chatbot;

import org.apache.camel.builder.endpoint.EndpointRouteBuilder;
import org.apache.camel.model.dataformat.BindyType;

public class CsvIngestor extends EndpointRouteBuilder {
@Override
public void configure() throws Exception {
from(file("src/main/resources/data?fileName=movies.csv").noop(true))
.unmarshal().bindy(BindyType.Csv, Movie.class)
.to(jpa(Movie.class.getName()+"?entityType=java.util.List"));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,63 @@
import jakarta.persistence.Id;
import jakarta.persistence.Table;

import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
import org.apache.camel.dataformat.bindy.annotation.DataField;
import org.hibernate.annotations.Comment;

import com.fasterxml.jackson.annotation.JsonProperty;

@Entity
@Table(name = "movie", schema = "public")
@CsvRecord(separator = ",", skipFirstLine = true )
public class Movie {

@Id
@GeneratedValue
private int id;

@Column(name = "index")
@DataField(pos = 1)
private int index;

@Column(name = "movie_name")
@JsonProperty("movie_name")
@DataField(pos = 2)
private String movieName;

@Column(name = "year_of_release")
@JsonProperty("year_of_release")
@DataField(pos = 3)
private int yearOfRelease;

@Column(name = "category")
@DataField(pos = 4)
private String category;

@Column(name = "run_time")
@JsonProperty("run_time")
@Comment("in minutes")
@DataField(pos = 5)
private int runTime;

@Column(name = "genre")
@Comment("this is a comma-separated list of genres")
@DataField(pos = 6)
private String genre;

@Column(name = "imdb_rating")
@JsonProperty("imdb_rating")
@DataField(pos = 7)
private float imdbRating;

@Column(name = "votes")
@DataField(pos = 8)
private Integer votes;

@Column(name = "gross_total")
@JsonProperty("gross_total")
@Comment("in millions of US dollars")
@DataField(pos = 9)
private float grossTotal;

public int getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class DemoTitle extends LitElement {
<h1>Movie Muse</h1>
</div>
<div class="explanation">
This demo shows how to build a chatbot powered by GPT 3.5 and advanced retrieval augmented generation.
This demo shows how to build a chatbot powered by GPT 4o-mini and advanced retrieval augmented generation.
The application ingested a CSV files listing the top 100 movies from IMDB.
You can now ask questions about the movies and the application will answer.
For example <em>What is the rating of the movie Inception?</em> or <em>What comedy movies are in the database?</em>
Expand Down

0 comments on commit c020ad0

Please sign in to comment.