Skip to content

Commit ab9f5f0

Browse files
feat(component): add ChatLLM binding for chat conversations
- Add ChatLLM binding to support separate LLM model for chat - Update CallLLMNode to use ChatLLM instead of CheapLLM - Update test fixtures to bind ChatLLM in all configurations - Update unit tests to include ChatLLM binding This enables 3 distinct LLM models: - SmartLLM: Query generation from scratch - CheapLLM: Query generation from cached samples - ChatLLM: Chat conversations
1 parent 6151729 commit ab9f5f0

9 files changed

Lines changed: 2967 additions & 3240 deletions

File tree

package-lock.json

Lines changed: 2952 additions & 3227 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__tests__/fixtures/test-app.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,23 @@ export class TestApp extends BootMixin(
4444
this.bind(AiIntegrationBindings.CheapLLM).toProvider(Ollama);
4545
this.bind(AiIntegrationBindings.SmartLLM).toProvider(Ollama);
4646
this.bind(AiIntegrationBindings.FileLLM).toProvider(Ollama);
47+
this.bind(AiIntegrationBindings.ChatLLM).toProvider(Ollama);
4748
this.bind(AiIntegrationBindings.EmbeddingModel).toProvider(
4849
OllamaEmbedding,
4950
);
5051
} else if (process.env.CEREBRAS === '1') {
5152
this.bind(AiIntegrationBindings.CheapLLM).toProvider(Cerebras);
5253
this.bind(AiIntegrationBindings.SmartLLM).toProvider(Cerebras);
5354
this.bind(AiIntegrationBindings.FileLLM).toProvider(Cerebras);
55+
this.bind(AiIntegrationBindings.ChatLLM).toProvider(Cerebras);
5456
this.bind(AiIntegrationBindings.EmbeddingModel).toProvider(
5557
OllamaEmbedding,
5658
);
5759
} else if (options.llmStub) {
5860
this.bind(AiIntegrationBindings.CheapLLM).to(options.llmStub);
5961
this.bind(AiIntegrationBindings.SmartLLM).to(options.llmStub);
6062
this.bind(AiIntegrationBindings.FileLLM).to(options.llmStub);
63+
this.bind(AiIntegrationBindings.ChatLLM).to(options.llmStub);
6164
this.bind(AiIntegrationBindings.EmbeddingModel).to(options.llmStub);
6265
}
6366
this.bind('datasources.readerdb').to(

src/__tests__/unit/nodes/call-llm.node.unit.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe('CallLLMNode Unit', function () {
3737
context.bind(AuthenticationBindings.CURRENT_USER).to(stubUser());
3838
context.bind(AiIntegrationBindings.SmartLLM).to(llmProvider);
3939
context.bind(AiIntegrationBindings.CheapLLM).to(llmProvider);
40+
context.bind(AiIntegrationBindings.ChatLLM).to(llmProvider);
4041
context.bind('datasources.readerdb').to(
4142
new juggler.DataSource({
4243
connector: 'sqlite3',

src/components/db-query/services/knowledge-graph/db-knowledge-graph.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ import {Concept, GraphEdge, GraphNode, KnowledgeGraph} from './types';
1818
const debug = require('debug')('ai-integration:knowledge-graph');
1919

2020
@injectable({scope: BindingScope.SINGLETON})
21-
export class DbKnowledgeGraphService
22-
implements KnowledgeGraph<string, DatabaseSchema>
23-
{
21+
export class DbKnowledgeGraphService implements KnowledgeGraph<
22+
string,
23+
DatabaseSchema
24+
> {
2425
edges: Map<string, GraphEdge[]>;
2526
nodes: Map<string, GraphNode>;
2627
private vectorWeight: number;

src/components/visualization/nodes/call-query-generation.node.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import {VisualizationGraphState} from '../state';
88
@graphNode(VisualizationGraphNodes.CallQueryGeneration, {
99
[POST_DATASET_TAG]: true,
1010
})
11-
export class CallQueryGenerationNode
12-
implements IGraphNode<VisualizationGraphState>
13-
{
11+
export class CallQueryGenerationNode implements IGraphNode<VisualizationGraphState> {
1412
constructor(
1513
@service(DbQueryGraph)
1614
private readonly queryPipeline: DbQueryGraph,

src/components/visualization/nodes/render-visualization.node.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import {POST_DATASET_TAG} from '../../db-query';
88
@graphNode(VisualizationGraphNodes.RenderVisualization, {
99
[POST_DATASET_TAG]: true,
1010
})
11-
export class RenderVisualizationNode
12-
implements IGraphNode<VisualizationGraphState>
13-
{
11+
export class RenderVisualizationNode implements IGraphNode<VisualizationGraphState> {
1412
constructor() {}
1513

1614
async execute(

src/components/visualization/nodes/select-visualization.node.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ import {POST_DATASET_TAG} from '../../db-query';
1515
@graphNode(VisualizationGraphNodes.SelectVisualisation, {
1616
[POST_DATASET_TAG]: true,
1717
})
18-
export class SelectVisualizationNode
19-
implements IGraphNode<VisualizationGraphState>
20-
{
18+
export class SelectVisualizationNode implements IGraphNode<VisualizationGraphState> {
2119
prompt = PromptTemplate.fromTemplate(`
2220
<instructions>
2321
You are expert Data Analysis Agent whose job is to suggest visualisations that would be best suited to display the results for a particular user prompt and the data extracted based on that prompt.

src/graphs/chat/nodes/call-llm.node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const debug = require('debug')('ai-integration:chat:call-llm.node');
1717
@graphNode(ChatNodes.CallLLM)
1818
export class CallLLMNode implements IGraphNode<ChatState> {
1919
constructor(
20-
@inject(AiIntegrationBindings.CheapLLM)
20+
@inject(AiIntegrationBindings.ChatLLM)
2121
private readonly llm: LLMProvider,
2222
@inject(AiIntegrationBindings.Tools)
2323
private readonly tools: ToolStore,

src/keys.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export namespace AiIntegrationBindings {
2424
export const FileLLM = BindingKey.create<LLMProvider>(
2525
'services.ai-reporting.fileLLMProvider',
2626
);
27+
export const ChatLLM = BindingKey.create<LLMProvider>(
28+
'services.ai-reporting.chatLLMProvider',
29+
);
2730
export const EmbeddingModel = BindingKey.create<EmbeddingProvider>(
2831
'services.ai-reporting.embeddingModel',
2932
);

0 commit comments

Comments
 (0)