@celljs/ai-core 4.6.1 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.en.md +64 -0
  2. package/package.json +3 -3
package/README.en.md ADDED
@@ -0,0 +1,64 @@
1
+ # Cell - AI Core Component
2
+
3
+ ## Overview
4
+
5
+ AI Core defines the common interfaces in Cell for interacting with AI models: chat model `ChatModel`, embedding model `EmbeddingModel`, prompt template `PromptTemplate`, and `ProxyChatModel` that routes by model name to concrete implementations. It doesn't call any model service itself; models are provided by components implementing these interfaces, currently [@celljs/ai-pi](../ai-pi) (based on pi-ai, connecting 20+ model providers).
6
+
7
+ ## Features
8
+
9
+ - Generate chat responses, with streaming support
10
+ - Prompt templates (variable substitution)
11
+ - `ProxyChatModel` routes requests by `<provider>:<model>` to the corresponding `ChatModel` implementation
12
+ - Embedding model interface `EmbeddingModel` (no implementation in this repo yet)
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @celljs/ai-core @celljs/ai-pi
18
+ ```
19
+
20
+ Installing takes effect immediately, no manual registration is needed. Model credentials and provider configuration are in [@celljs/ai-pi](../ai-pi).
21
+
22
+ ## Quick Start
23
+
24
+ ```typescript
25
+ import { type ChatModel, PromptTemplate, ProxyChatModel } from '@celljs/ai-core';
26
+ import { Autowired, Component } from '@celljs/core';
27
+
28
+ @Component()
29
+ export class Assistant {
30
+ @Autowired(ProxyChatModel)
31
+ protected readonly chatModel: ChatModel;
32
+
33
+ @Autowired(PromptTemplate)
34
+ protected readonly promptTemplate: PromptTemplate;
35
+
36
+ async chat(name: string): Promise<string> {
37
+ const prompt = await this.promptTemplate.create('Hello {name}', {
38
+ variables: { name },
39
+ // pi:<provider>/<model id>: ProxyChatModel routes by pi before the first colon to @celljs/ai-pi
40
+ chatOptions: { model: 'pi:anthropic/claude-sonnet-4-5' }
41
+ });
42
+ const response = await this.chatModel.call(prompt);
43
+ return response.result.output.content;
44
+ }
45
+
46
+ async stream(name: string): Promise<void> {
47
+ const prompt = await this.promptTemplate.create('Hello {name}', {
48
+ variables: { name },
49
+ chatOptions: { model: 'pi:anthropic/claude-sonnet-4-5' }
50
+ });
51
+ const response$ = await this.chatModel.stream(prompt);
52
+ response$.subscribe({
53
+ next: response => console.log(response.result.output.content),
54
+ complete: () => console.log('Chat completed!')
55
+ });
56
+ }
57
+ }
58
+ ```
59
+
60
+ Model names must be in `<provider>:<model>` form; `ProxyChatModel` throws `IllegalArgumentError` otherwise.
61
+
62
+ ## License
63
+
64
+ This project is licensed under the MIT License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ai-core",
3
- "version": "4.6.1",
3
+ "version": "4.8.0",
4
4
  "description": "Core domain for AI programming",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -31,8 +31,8 @@
31
31
  "watch": "tsc -b -w --preserveWatchOutput"
32
32
  },
33
33
  "dependencies": {
34
- "@celljs/core": "4.6.1",
35
- "@celljs/http": "4.6.1",
34
+ "@celljs/core": "4.8.0",
35
+ "@celljs/http": "4.8.0",
36
36
  "rxjs": "^6.6.0"
37
37
  },
38
38
  "publishConfig": {