@ancatag/n-r 0.1.19 → 0.2.1

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.
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)
9
9
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)
10
10
 
11
- **Nova-route** is an AI infrastructure platform that reduces your AI API costs by 60-80% through intelligent caching, semantic similarity matching, and RAG optimization. This SDK provides a drop-in replacement for OpenAI with automatic cost savings.
11
+ **Nova-route** is an AI infrastructure platform that reduces your AI API costs by 60-80% through intelligent caching, semantic similarity matching, and RAG optimization. This SDK provides a drop-in replacement for OpenAI with automatic cost savings and route-config-based AI orchestration.
12
12
 
13
13
  ## Features
14
14
 
@@ -45,8 +45,22 @@ const client = new NovaClient({
45
45
  apiKey: process.env.NOVA_API_KEY || 'nova_sk_...',
46
46
  });
47
47
 
48
+ // Recommended: Use route config ID for consistent behavior
48
49
  const response = await client.chat.create({
49
- model: 'llama2', // or any model configured in your project
50
+ messages: [
51
+ { role: 'system', content: 'You are a helpful assistant.' },
52
+ { role: 'user', content: 'Hello!' }
53
+ ],
54
+ temperature: 0.7,
55
+ max_tokens: 1000,
56
+ nova: {
57
+ routeConfigId: 'your-route-config-id' // Use specific route config
58
+ }
59
+ });
60
+
61
+ // Legacy: Model field still supported but route config recommended
62
+ const responseLegacy = await client.chat.create({
63
+ model: 'llama2', // Falls back to project default model
50
64
  messages: [
51
65
  { role: 'system', content: 'You are a helpful assistant.' },
52
66
  { role: 'user', content: 'Hello!' }
@@ -65,9 +79,11 @@ console.log('Tokens saved:', response.nova?.tokensSaved);
65
79
 
66
80
  ```typescript
67
81
  const stream = client.chat.createStream({
68
- model: 'llama2',
69
82
  messages: [{ role: 'user', content: 'Tell me a story' }],
70
83
  temperature: 0.7,
84
+ nova: {
85
+ routeConfigId: 'your-route-config-id' // Recommended: use route config
86
+ }
71
87
  });
72
88
 
73
89
  for await (const chunk of stream) {
@@ -1,19 +1,15 @@
1
- /**
2
- * gRPC Client (stub implementation)
3
- *
4
- * This is a placeholder for gRPC functionality.
5
- * OpenChat uses REST transport only, so this is not implemented.
6
- *
7
- * To implement gRPC support, this would use @grpc/grpc-js and @nova-ai/proto
8
- *
9
- * Note: gRPC dependencies are optional. If gRPC is requested but dependencies
10
- * are not installed, this will throw an error suggesting to use REST instead.
11
- */
12
1
  import type { ChatCompletionChunk, ChatCompletionRequest, ChatCompletionResponse, Model, NovaClientConfig } from "./types.js";
13
2
  export declare class GrpcClient {
14
- constructor(_config: NovaClientConfig);
15
- createChatCompletion(_request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
16
- createChatCompletionStream(_request: ChatCompletionRequest): AsyncGenerator<ChatCompletionChunk, void, unknown>;
3
+ private readonly config;
4
+ private client;
5
+ private proto;
6
+ constructor(config: NovaClientConfig);
7
+ private getMetadata;
8
+ createChatCompletion(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
9
+ createChatCompletionStream(request: ChatCompletionRequest): AsyncGenerator<ChatCompletionChunk, void, unknown>;
17
10
  listModels(): Promise<Model[]>;
11
+ private mapToGrpcRequest;
12
+ private mapFromGrpcResponse;
13
+ private mapFromGrpcStreamResponse;
18
14
  }
19
15
  //# sourceMappingURL=grpc-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"grpc-client.d.ts","sourceRoot":"","sources":["../src/grpc-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACX,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,KAAK,EACL,gBAAgB,EAChB,MAAM,YAAY,CAAC;AAEpB,qBAAa,UAAU;gBACV,OAAO,EAAE,gBAAgB;IAW/B,oBAAoB,CACzB,QAAQ,EAAE,qBAAqB,GAC7B,OAAO,CAAC,sBAAsB,CAAC;IAI3B,0BAA0B,CAChC,QAAQ,EAAE,qBAAqB,GAC7B,cAAc,CAAC,mBAAmB,EAAE,IAAI,EAAE,OAAO,CAAC;IAI/C,UAAU,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;CAGpC"}
1
+ {"version":3,"file":"grpc-client.d.ts","sourceRoot":"","sources":["../src/grpc-client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,KAAK,EACL,gBAAgB,EAChB,MAAM,YAAY,CAAC;AAEpB,qBAAa,UAAU;IAIV,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,KAAK,CAAM;gBAEU,MAAM,EAAE,gBAAgB;IAoBrD,OAAO,CAAC,WAAW;IAMb,oBAAoB,CACzB,OAAO,EAAE,qBAAqB,GAC5B,OAAO,CAAC,sBAAsB,CAAC;IAmB3B,0BAA0B,CAChC,OAAO,EAAE,qBAAqB,GAC5B,cAAc,CAAC,mBAAmB,EAAE,IAAI,EAAE,OAAO,CAAC;IAW/C,UAAU,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAoBpC,OAAO,CAAC,gBAAgB;IAwBxB,OAAO,CAAC,mBAAmB;IA+B3B,OAAO,CAAC,yBAAyB;CAiBjC"}
@@ -1,31 +1,134 @@
1
- /**
2
- * gRPC Client (stub implementation)
3
- *
4
- * This is a placeholder for gRPC functionality.
5
- * OpenChat uses REST transport only, so this is not implemented.
6
- *
7
- * To implement gRPC support, this would use @grpc/grpc-js and @nova-ai/proto
8
- *
9
- * Note: gRPC dependencies are optional. If gRPC is requested but dependencies
10
- * are not installed, this will throw an error suggesting to use REST instead.
11
- */
1
+ import * as grpc from "@grpc/grpc-js";
2
+ import * as protoLoader from "@grpc/proto-loader";
3
+ import { NOVA_SERVICE_PROTO } from "@nova-ai/proto";
12
4
  export class GrpcClient {
13
- constructor(_config) {
14
- // Stub implementation - gRPC not fully implemented yet
15
- // Note: gRPC dependencies (@grpc/grpc-js, @grpc/proto-loader) are optional
16
- // If you need gRPC support, install them: pnpm add @grpc/grpc-js @grpc/proto-loader
17
- // For now, use REST transport: transport: "rest"
18
- throw new Error('gRPC transport is not fully implemented. Use transport: "rest" instead.\n' +
19
- "If you need gRPC support, ensure @grpc/grpc-js and @grpc/proto-loader are installed.");
5
+ config;
6
+ client;
7
+ proto;
8
+ constructor(config) {
9
+ this.config = config;
10
+ const packageDefinition = protoLoader.loadSync(NOVA_SERVICE_PROTO, {
11
+ keepCase: true,
12
+ longs: String,
13
+ enums: String,
14
+ defaults: true,
15
+ oneofs: true,
16
+ });
17
+ const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
18
+ const novaService = protoDescriptor.nova.service;
19
+ const grpcUrl = config.grpcUrl || "0.0.0.0:50051";
20
+ this.client = new novaService.NovaService(grpcUrl, grpc.credentials.createInsecure());
21
+ this.proto = protoDescriptor.nova.service;
20
22
  }
21
- async createChatCompletion(_request) {
22
- throw new Error("gRPC not implemented");
23
+ getMetadata(apiKey) {
24
+ const metadata = new grpc.Metadata();
25
+ metadata.add("authorization", `Bearer ${apiKey}`);
26
+ return metadata;
23
27
  }
24
- async *createChatCompletionStream(_request) {
25
- throw new Error("gRPC not implemented");
28
+ async createChatCompletion(request) {
29
+ return new Promise((resolve, reject) => {
30
+ const grpcRequest = this.mapToGrpcRequest(request);
31
+ const metadata = this.getMetadata(this.config.apiKey);
32
+ this.client.GenerateText(grpcRequest, metadata, { deadline: new Date(Date.now() + (this.config.timeoutMs || 60000)) }, (error, response) => {
33
+ if (error) {
34
+ return reject(error);
35
+ }
36
+ resolve(this.mapFromGrpcResponse(response));
37
+ });
38
+ });
39
+ }
40
+ async *createChatCompletionStream(request) {
41
+ const grpcRequest = this.mapToGrpcRequest(request);
42
+ const metadata = this.getMetadata(this.config.apiKey);
43
+ const stream = this.client.StreamText(grpcRequest, metadata);
44
+ for await (const chunk of stream) {
45
+ yield this.mapFromGrpcStreamResponse(chunk);
46
+ }
26
47
  }
27
48
  async listModels() {
28
- throw new Error("gRPC not implemented");
49
+ return new Promise((resolve, reject) => {
50
+ const metadata = this.getMetadata(this.config.apiKey);
51
+ this.client.ListModels({}, metadata, (error, response) => {
52
+ if (error) {
53
+ return reject(error);
54
+ }
55
+ resolve(response.models.map((m) => ({
56
+ id: m.id,
57
+ object: "model",
58
+ created: Math.floor(Date.now() / 1000),
59
+ owned_by: m.provider || "nova",
60
+ })));
61
+ });
62
+ });
63
+ }
64
+ mapToGrpcRequest(request) {
65
+ // Map OpenAI-style request to Nova gRPC request
66
+ const lastMessage = request.messages[request.messages.length - 1];
67
+ return {
68
+ prompt: lastMessage.content,
69
+ model_selection: {
70
+ model_id: request.model,
71
+ },
72
+ max_tokens: request.max_tokens,
73
+ temperature: request.temperature,
74
+ top_p: request.top_p,
75
+ context: {
76
+ conversation_history: request.messages.slice(0, -1).map((m) => ({
77
+ role: m.role,
78
+ content: m.content,
79
+ })),
80
+ },
81
+ // Nova extensions
82
+ enable_cache: !request.nova?.skipCache,
83
+ enable_semantic_cache: !request.nova?.skipCache,
84
+ };
85
+ }
86
+ mapFromGrpcResponse(response) {
87
+ return {
88
+ id: response.result?.metadata?.request_id || `chatcmpl-${Date.now()}`,
89
+ object: "chat.completion",
90
+ created: Math.floor(Date.now() / 1000),
91
+ model: response.used_model?.model_id || "unknown",
92
+ choices: [
93
+ {
94
+ index: 0,
95
+ message: {
96
+ role: "assistant",
97
+ content: response.result?.result || "",
98
+ },
99
+ finish_reason: "stop",
100
+ },
101
+ ],
102
+ usage: {
103
+ prompt_tokens: response.usage?.input_tokens || 0,
104
+ completion_tokens: response.usage?.output_tokens || 0,
105
+ total_tokens: response.usage?.total_tokens || 0,
106
+ },
107
+ nova: {
108
+ cacheHit: response.cached || false,
109
+ cacheLayer: response.semantic_cache_hit ? "semantic" : "hot",
110
+ tokensSaved: response.usage?.total_tokens || 0, // Simplified
111
+ responseTimeMs: 0, // Not available in raw gRPC response easily
112
+ requestId: response.result?.metadata?.request_id || "",
113
+ },
114
+ };
115
+ }
116
+ mapFromGrpcStreamResponse(chunk) {
117
+ return {
118
+ id: `chatcmpl-${Date.now()}`,
119
+ object: "chat.completion.chunk",
120
+ created: Math.floor(Date.now() / 1000),
121
+ model: chunk.used_model?.model_id || "unknown",
122
+ choices: [
123
+ {
124
+ index: 0,
125
+ delta: {
126
+ content: chunk.token || "",
127
+ },
128
+ finish_reason: chunk.completed ? "stop" : null,
129
+ },
130
+ ],
131
+ };
29
132
  }
30
133
  }
31
134
  //# sourceMappingURL=grpc-client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"grpc-client.js","sourceRoot":"","sources":["../src/grpc-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH,MAAM,OAAO,UAAU;IACtB,YAAY,OAAyB;QACpC,uDAAuD;QACvD,2EAA2E;QAC3E,oFAAoF;QACpF,iDAAiD;QACjD,MAAM,IAAI,KAAK,CACd,2EAA2E;YAC1E,sFAAsF,CACvF,CAAC;IACH,CAAC;IAED,KAAK,CAAC,oBAAoB,CACzB,QAA+B;QAE/B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,CAAC,0BAA0B,CAChC,QAA+B;QAE/B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,UAAU;QACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACzC,CAAC;CACD"}
1
+ {"version":3,"file":"grpc-client.js","sourceRoot":"","sources":["../src/grpc-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AASpD,MAAM,OAAO,UAAU;IAIO;IAHrB,MAAM,CAAM;IAC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AAE;gBACR;oBACC,KAAK,EAAE,CAAC;oBACR,KAAK,EAAE;wBACN,OAAO,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE;qBAC1B;oBACD,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;iBAC9C;aACD;SACD,CAAC;IACH,CAAC;CACD"}
package/dist/index.d.ts CHANGED
@@ -14,19 +14,20 @@
14
14
  * baseUrl: 'http://localhost:3000', // optional
15
15
  * });
16
16
  *
17
- * // Non-streaming
17
+ * // Non-streaming - Recommended: use route config ID
18
18
  * const response = await client.chat.create({
19
- * model: 'llama2',
20
19
  * messages: [{ role: 'user', content: 'Hello!' }],
21
20
  * nova: {
22
- * routeConfigId: 'route-config-uuid', // Optional: specify route config
21
+ * routeConfigId: 'route-config-uuid', // Recommended: specify route config
23
22
  * },
24
23
  * });
25
24
  *
26
- * // Streaming
25
+ * // Streaming - Recommended: use route config ID
27
26
  * for await (const chunk of client.chat.createStream({
28
- * model: 'llama2',
29
27
  * messages: [{ role: 'user', content: 'Hello!' }],
28
+ * nova: {
29
+ * routeConfigId: 'route-config-uuid',
30
+ * },
30
31
  * })) {
31
32
  * console.log(chunk.choices[0]?.delta?.content || '');
32
33
  * }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EACX,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,WAAW,EACX,KAAK,EACL,gBAAgB,EAChB,aAAa,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EACX,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,WAAW,EACX,KAAK,EACL,gBAAgB,EAChB,aAAa,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -14,19 +14,20 @@
14
14
  * baseUrl: 'http://localhost:3000', // optional
15
15
  * });
16
16
  *
17
- * // Non-streaming
17
+ * // Non-streaming - Recommended: use route config ID
18
18
  * const response = await client.chat.create({
19
- * model: 'llama2',
20
19
  * messages: [{ role: 'user', content: 'Hello!' }],
21
20
  * nova: {
22
- * routeConfigId: 'route-config-uuid', // Optional: specify route config
21
+ * routeConfigId: 'route-config-uuid', // Recommended: specify route config
23
22
  * },
24
23
  * });
25
24
  *
26
- * // Streaming
25
+ * // Streaming - Recommended: use route config ID
27
26
  * for await (const chunk of client.chat.createStream({
28
- * model: 'llama2',
29
27
  * messages: [{ role: 'user', content: 'Hello!' }],
28
+ * nova: {
29
+ * routeConfigId: 'route-config-uuid',
30
+ * },
30
31
  * })) {
31
32
  * console.log(chunk.choices[0]?.delta?.content || '');
32
33
  * }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAcrC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAcrC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ancatag/n-r",
3
- "version": "0.1.19",
4
- "description": "Official Node.js/TypeScript SDK for Nova AI API",
3
+ "version": "0.2.1",
4
+ "description": "Official Node.js/TypeScript SDK for Nova AI API with route-config-based orchestration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -32,7 +32,11 @@
32
32
  "sdk",
33
33
  "chat",
34
34
  "completions",
35
- "openai-compatible"
35
+ "openai-compatible",
36
+ "route-config",
37
+ "caching",
38
+ "rag",
39
+ "cost-optimization"
36
40
  ],
37
41
  "author": "",
38
42
  "license": "ISC",
@@ -54,8 +58,9 @@
54
58
  "vitest": "^4.0.16"
55
59
  },
56
60
  "type": "module",
57
- "optionalDependencies": {
61
+ "dependencies": {
58
62
  "@grpc/grpc-js": "^1.14.3",
59
- "@grpc/proto-loader": "^0.8.0"
63
+ "@grpc/proto-loader": "^0.8.0",
64
+ "@nova-ai/proto": "workspace:*"
60
65
  }
61
66
  }