Skip to content

Commit bdfabb7

Browse files
jkwatsonewilliams-clouderaactions-user
authored
CAII endpoint discovery (#60)
* "wip on endpoint listing" * "wip on list_endpoints typing" * "refactoring to endpoint object" * "wip filtering" * "endpoints queried!" * "refactoring" * "wip on cleaning up types" * "type cleanup complete" * "moving files" * "use a dummy embedding model for deletes" * fix some bits from merge, get evals working again with CAII, tests passing * formatting * clean up ruff stuff * use the chat llm for evals * fix mypy for reformatting * "wip on java reconciler" * "reconciler don't do no model; start python work" * "python - updating for summarization model" * "comment out batch embeddings to get it working again" * add handling for no summarization in the files table * finish up ui and python for summarization * make sure to update the time-updated fields on data sources and chat sessions * use no-op models when we don't need real ones for summary functionality * Update release version to dev-testing * use the summarization llm when summarizing summaries --------- Co-authored-by: Elijah Williams <[email protected]> Co-authored-by: actions-user <[email protected]>
1 parent 2dac585 commit bdfabb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+995
-338
lines changed

.env.example

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ DB_URL=jdbc:h2:../databases/rag
1212

1313
# If using CAII, fill these in:
1414
CAII_DOMAIN=
15-
CAII_INFERENCE_ENDPOINT_NAME=
16-
CAII_EMBEDDING_ENDPOINT_NAME=
1715

1816
# set this to true if you have uv installed on your system, other wise don't include this
1917
USE_SYSTEM_UV=true

.project-metadata.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ environment_variables:
3434
default: ""
3535
description: "The domain of the CAII service. Setting this will enable CAII as the sole source for both inference and embedding models."
3636
required: false
37-
CAII_INFERENCE_ENDPOINT_NAME:
38-
default: ""
39-
description: "The name of the inference endpoint for the CAII service. Required if CAII_DOMAIN is set."
40-
required: false
41-
CAII_EMBEDDING_ENDPOINT_NAME:
42-
default: ""
43-
description: "The name of the embedding endpoint for the CAII service. Required if CAII_DOMAIN is set."
44-
required: false
4537
DB_URL:
4638
default: "jdbc:h2:file:~/databases/rag"
4739
description: "Internal DB URL. Do not change."

backend/src/main/java/com/cloudera/cai/rag/Types.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public record RagDataSource(
8181
Long id,
8282
String name,
8383
String embeddingModel,
84+
String summarizationModel,
8485
Integer chunkSize,
8586
Integer chunkOverlapPercent,
8687
Instant timeCreated,

backend/src/main/java/com/cloudera/cai/rag/datasources/RagDataSourceRepository.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.cloudera.cai.rag.Types.RagDataSource;
4242
import com.cloudera.cai.rag.configuration.JdbiConfiguration;
4343
import com.cloudera.cai.util.exceptions.NotFound;
44+
import java.time.Instant;
4445
import java.util.List;
4546
import lombok.extern.slf4j.Slf4j;
4647
import org.jdbi.v3.core.Jdbi;
@@ -62,8 +63,8 @@ public Long createRagDataSource(RagDataSource input) {
6263
handle -> {
6364
var sql =
6465
"""
65-
INSERT INTO rag_data_source (name, chunk_size, chunk_overlap_percent, created_by_id, updated_by_id, connection_type, embedding_model)
66-
VALUES (:name, :chunkSize, :chunkOverlapPercent, :createdById, :updatedById, :connectionType, :embeddingModel)
66+
INSERT INTO rag_data_source (name, chunk_size, chunk_overlap_percent, created_by_id, updated_by_id, connection_type, embedding_model, summarization_model)
67+
VALUES (:name, :chunkSize, :chunkOverlapPercent, :createdById, :updatedById, :connectionType, :embeddingModel, :summarizationModel)
6768
""";
6869
try (var update = handle.createUpdate(sql)) {
6970
update.bindMethods(input);
@@ -78,7 +79,7 @@ public void updateRagDataSource(RagDataSource input) {
7879
var sql =
7980
"""
8081
UPDATE rag_data_source
81-
SET name = :name, connection_type = :connectionType, updated_by_id = :updatedById
82+
SET name = :name, connection_type = :connectionType, updated_by_id = :updatedById, summarization_model = :summarizationModel, time_updated = :now
8283
WHERE id = :id AND deleted IS NULL
8384
""";
8485
try (var update = handle.createUpdate(sql)) {
@@ -87,6 +88,8 @@ public void updateRagDataSource(RagDataSource input) {
8788
.bind("updatedById", input.updatedById())
8889
.bind("connectionType", input.connectionType())
8990
.bind("id", input.id())
91+
.bind("summarizationModel", input.summarizationModel())
92+
.bind("now", Instant.now())
9093
.execute();
9194
}
9295
});

backend/src/main/java/com/cloudera/cai/rag/files/RagFileSummaryReconciler.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ public void resync() {
8585
log.debug("checking for RAG documents to be summarized");
8686
String sql =
8787
"""
88-
SELECT * from rag_data_source_document
89-
WHERE summary_creation_timestamp IS NULL
90-
AND time_created > :yesterday
88+
SELECT rdsd.* from rag_data_source_document rdsd
89+
JOIN rag_data_source rds ON rdsd.data_source_id = rds.id
90+
WHERE rdsd.summary_creation_timestamp IS NULL
91+
AND (rdsd.time_created > :yesterday OR rds.time_updated > :yesterday)
92+
AND rds.summarization_model IS NOT NULL
9193
""";
9294
jdbi.useHandle(
9395
handle -> {

backend/src/main/java/com/cloudera/cai/rag/sessions/SessionRepository.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,16 @@ public void delete(Long id) {
164164
}
165165

166166
public void update(Types.Session input) {
167+
var updatedInput = input.withTimeUpdated(Instant.now());
167168
jdbi.useHandle(
168169
handle -> {
169170
var sql =
170171
"""
171172
UPDATE CHAT_SESSION
172-
SET name = :name, updated_by_id = :updatedById, inference_model = :inferenceModel, response_chunks = :responseChunks
173+
SET name = :name, updated_by_id = :updatedById, inference_model = :inferenceModel, response_chunks = :responseChunks, time_updated = :timeUpdated
173174
WHERE id = :id
174175
""";
175-
handle.createUpdate(sql).bindMethods(input).execute();
176+
handle.createUpdate(sql).bindMethods(updatedInput).execute();
176177
});
177178
}
178179
}

backend/src/main/java/com/cloudera/cai/util/IdGenerator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
package com.cloudera.cai.util;
4040

41+
import java.util.Random;
4142
import java.util.UUID;
4243
import org.springframework.stereotype.Component;
4344

@@ -53,6 +54,7 @@ public static IdGenerator createNull(String... dummyIds) {
5354
}
5455

5556
private static class NullIdGenerator extends IdGenerator {
57+
private final Random random = new Random();
5658

5759
private final String[] dummyIds;
5860

@@ -62,7 +64,7 @@ private NullIdGenerator(String[] dummyIds) {
6264

6365
@Override
6466
public String generateId() {
65-
return dummyIds.length == 0 ? "StubbedId" : dummyIds[0];
67+
return dummyIds.length == 0 ? "StubbedId-" + random.nextInt() : dummyIds[0];
6668
}
6769
}
6870
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* CLOUDERA APPLIED MACHINE LEARNING PROTOTYPE (AMP)
3+
* (C) Cloudera, Inc. 2024
4+
* All rights reserved.
5+
*
6+
* Applicable Open Source License: Apache 2.0
7+
*
8+
* NOTE: Cloudera open source products are modular software products
9+
* made up of hundreds of individual components, each of which was
10+
* individually copyrighted. Each Cloudera open source product is a
11+
* collective work under U.S. Copyright Law. Your license to use the
12+
* collective work is as provided in your written agreement with
13+
* Cloudera. Used apart from the collective work, this file is
14+
* licensed for your use pursuant to the open source license
15+
* identified above.
16+
*
17+
* This code is provided to you pursuant a written agreement with
18+
* (i) Cloudera, Inc. or (ii) a third-party authorized to distribute
19+
* this code. If you do not have a written agreement with Cloudera nor
20+
* with an authorized and properly licensed third party, you do not
21+
* have any rights to access nor to use this code.
22+
*
23+
* Absent a written agreement with Cloudera, Inc. (“Cloudera”) to the
24+
* contrary, A) CLOUDERA PROVIDES THIS CODE TO YOU WITHOUT WARRANTIES OF ANY
25+
* KIND; (B) CLOUDERA DISCLAIMS ANY AND ALL EXPRESS AND IMPLIED
26+
* WARRANTIES WITH RESPECT TO THIS CODE, INCLUDING BUT NOT LIMITED TO
27+
* IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND
28+
* FITNESS FOR A PARTICULAR PURPOSE; (C) CLOUDERA IS NOT LIABLE TO YOU,
29+
* AND WILL NOT DEFEND, INDEMNIFY, NOR HOLD YOU HARMLESS FOR ANY CLAIMS
30+
* ARISING FROM OR RELATED TO THE CODE; AND (D)WITH RESPECT TO YOUR EXERCISE
31+
* OF ANY RIGHTS GRANTED TO YOU FOR THE CODE, CLOUDERA IS NOT LIABLE FOR ANY
32+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR
33+
* CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT LIMITED TO, DAMAGES
34+
* RELATED TO LOST REVENUE, LOST PROFITS, LOSS OF INCOME, LOSS OF
35+
* BUSINESS ADVANTAGE OR UNAVAILABILITY, OR LOSS OR CORRUPTION OF
36+
* DATA.
37+
*/
38+
39+
SET MODE MYSQL;
40+
41+
BEGIN;
42+
43+
ALTER TABLE rag_data_source DROP COLUMN summarization_model;
44+
45+
COMMIT;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* CLOUDERA APPLIED MACHINE LEARNING PROTOTYPE (AMP)
3+
* (C) Cloudera, Inc. 2024
4+
* All rights reserved.
5+
*
6+
* Applicable Open Source License: Apache 2.0
7+
*
8+
* NOTE: Cloudera open source products are modular software products
9+
* made up of hundreds of individual components, each of which was
10+
* individually copyrighted. Each Cloudera open source product is a
11+
* collective work under U.S. Copyright Law. Your license to use the
12+
* collective work is as provided in your written agreement with
13+
* Cloudera. Used apart from the collective work, this file is
14+
* licensed for your use pursuant to the open source license
15+
* identified above.
16+
*
17+
* This code is provided to you pursuant a written agreement with
18+
* (i) Cloudera, Inc. or (ii) a third-party authorized to distribute
19+
* this code. If you do not have a written agreement with Cloudera nor
20+
* with an authorized and properly licensed third party, you do not
21+
* have any rights to access nor to use this code.
22+
*
23+
* Absent a written agreement with Cloudera, Inc. (“Cloudera”) to the
24+
* contrary, A) CLOUDERA PROVIDES THIS CODE TO YOU WITHOUT WARRANTIES OF ANY
25+
* KIND; (B) CLOUDERA DISCLAIMS ANY AND ALL EXPRESS AND IMPLIED
26+
* WARRANTIES WITH RESPECT TO THIS CODE, INCLUDING BUT NOT LIMITED TO
27+
* IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND
28+
* FITNESS FOR A PARTICULAR PURPOSE; (C) CLOUDERA IS NOT LIABLE TO YOU,
29+
* AND WILL NOT DEFEND, INDEMNIFY, NOR HOLD YOU HARMLESS FOR ANY CLAIMS
30+
* ARISING FROM OR RELATED TO THE CODE; AND (D)WITH RESPECT TO YOUR EXERCISE
31+
* OF ANY RIGHTS GRANTED TO YOU FOR THE CODE, CLOUDERA IS NOT LIABLE FOR ANY
32+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR
33+
* CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT LIMITED TO, DAMAGES
34+
* RELATED TO LOST REVENUE, LOST PROFITS, LOSS OF INCOME, LOSS OF
35+
* BUSINESS ADVANTAGE OR UNAVAILABILITY, OR LOSS OR CORRUPTION OF
36+
* DATA.
37+
*/
38+
39+
SET MODE MYSQL;
40+
41+
BEGIN;
42+
43+
ALTER TABLE rag_data_source ADD COLUMN summarization_model varchar(255);
44+
45+
COMMIT;

backend/src/main/resources/migrations/migrations.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@
2626
13_add_chat_configuration.down.sql
2727
13_add_chat_configuration.up.sql
2828
14_add_embedding_model.down.sql
29-
14_add_embedding_model.up.sql
29+
14_add_embedding_model.up.sql
30+
15_add_summarization_model.down.sql
31+
15_add_summarization_model.up.sql

0 commit comments

Comments
 (0)