@llumiverse/core 0.8.4 → 0.9.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.
Files changed (70) hide show
  1. package/lib/cjs/Driver.js +2 -2
  2. package/lib/cjs/Driver.js.map +1 -1
  3. package/lib/cjs/async.js +21 -1
  4. package/lib/cjs/async.js.map +1 -1
  5. package/lib/cjs/formatters/claude.js +57 -0
  6. package/lib/cjs/formatters/claude.js.map +1 -0
  7. package/lib/cjs/formatters/generic.js +27 -0
  8. package/lib/cjs/formatters/generic.js.map +1 -0
  9. package/lib/cjs/formatters/index.js +31 -0
  10. package/lib/cjs/formatters/index.js.map +1 -0
  11. package/lib/cjs/formatters/llama2.js +49 -0
  12. package/lib/cjs/formatters/llama2.js.map +1 -0
  13. package/lib/cjs/formatters/openai.js +24 -0
  14. package/lib/cjs/formatters/openai.js.map +1 -0
  15. package/lib/cjs/index.js +1 -1
  16. package/lib/cjs/index.js.map +1 -1
  17. package/lib/cjs/types.js +1 -0
  18. package/lib/cjs/types.js.map +1 -1
  19. package/lib/esm/Driver.js +1 -1
  20. package/lib/esm/Driver.js.map +1 -1
  21. package/lib/esm/async.js +19 -0
  22. package/lib/esm/async.js.map +1 -1
  23. package/lib/esm/formatters/claude.js +53 -0
  24. package/lib/esm/formatters/claude.js.map +1 -0
  25. package/lib/esm/formatters/generic.js +23 -0
  26. package/lib/esm/formatters/generic.js.map +1 -0
  27. package/lib/esm/formatters/index.js +27 -0
  28. package/lib/esm/formatters/index.js.map +1 -0
  29. package/lib/esm/formatters/llama2.js +45 -0
  30. package/lib/esm/formatters/llama2.js.map +1 -0
  31. package/lib/esm/formatters/openai.js +20 -0
  32. package/lib/esm/formatters/openai.js.map +1 -0
  33. package/lib/esm/index.js +1 -1
  34. package/lib/esm/index.js.map +1 -1
  35. package/lib/esm/types.js +1 -0
  36. package/lib/esm/types.js.map +1 -1
  37. package/lib/types/Driver.d.ts +1 -1
  38. package/lib/types/Driver.d.ts.map +1 -1
  39. package/lib/types/async.d.ts +5 -0
  40. package/lib/types/async.d.ts.map +1 -1
  41. package/lib/types/formatters/claude.d.ts +19 -0
  42. package/lib/types/formatters/claude.d.ts.map +1 -0
  43. package/lib/types/formatters/generic.d.ts +8 -0
  44. package/lib/types/formatters/generic.d.ts.map +1 -0
  45. package/lib/types/{formatters.d.ts → formatters/index.d.ts} +2 -2
  46. package/lib/types/formatters/index.d.ts.map +1 -0
  47. package/lib/types/formatters/llama2.d.ts +4 -0
  48. package/lib/types/formatters/llama2.d.ts.map +1 -0
  49. package/lib/types/formatters/openai.d.ts +4 -0
  50. package/lib/types/formatters/openai.d.ts.map +1 -0
  51. package/lib/types/index.d.ts +1 -1
  52. package/lib/types/index.d.ts.map +1 -1
  53. package/lib/types/types.d.ts +6 -2
  54. package/lib/types/types.d.ts.map +1 -1
  55. package/package.json +2 -1
  56. package/src/Driver.ts +2 -2
  57. package/src/async.ts +19 -0
  58. package/src/formatters/claude.ts +74 -0
  59. package/src/formatters/generic.ts +34 -0
  60. package/src/formatters/index.ts +33 -0
  61. package/src/formatters/llama2.ts +58 -0
  62. package/src/formatters/openai.ts +22 -0
  63. package/src/index.ts +1 -1
  64. package/src/types.ts +6 -1
  65. package/lib/cjs/formatters.js +0 -117
  66. package/lib/cjs/formatters.js.map +0 -1
  67. package/lib/esm/formatters.js +0 -113
  68. package/lib/esm/formatters.js.map +0 -1
  69. package/lib/types/formatters.d.ts.map +0 -1
  70. package/src/formatters.ts +0 -147
package/lib/esm/types.js CHANGED
@@ -51,6 +51,7 @@ export var BuiltinProviders;
51
51
  BuiltinProviders["bedrock"] = "bedrock";
52
52
  BuiltinProviders["vertexai"] = "vertexai";
53
53
  BuiltinProviders["togetherai"] = "togetherai";
54
+ BuiltinProviders["mistralai"] = "mistralai";
54
55
  //virtual = 'virtual',
55
56
  //cohere = 'cohere',
56
57
  })(BuiltinProviders || (BuiltinProviders = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sour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AiB,CAAA;IACjB,kDAAiC,CAAA;AACrC,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AAED,MAAM,CAAN,IAAY,gBAUX;AAVD,WAAY,gBAAgB;IACxB,qCAAiB,CAAA;IACjB,qDAAiC,CAAA;IACjC,2CAAuB,CAAA;IACvB,uCAAmB,CAAA;IACnB,yCAAqB,CAAA;IACrB,6CAAyB,CAAA;IACzB,2CAAuB,CAAA;IACvB,0BAA0B;IAC1B,oBAAoB;AACxB,CAAC,EAVW,gBAAgB,KAAhB,gBAAgB,QAU3B;AAwBD,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IACzB,wCAAmB,CAAA;IACnB,4CAAuB,CAAA;IACvB,sCAAiB,CAAA;IACjB,4CAAuB,CAAA;AAC3B,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B"}
@@ -57,7 +57,7 @@ export declare abstract class AbstractDriver<OptionsT extends DriverOptions = Dr
57
57
  protected canStream(_options: ExecutionOptions): Promise<boolean>;
58
58
  abstract requestCompletion(prompt: PromptT, options: ExecutionOptions): Promise<Completion>;
59
59
  abstract requestCompletionStream(prompt: PromptT, options: ExecutionOptions): Promise<AsyncIterable<string>>;
60
- abstract listModels(params: ModelSearchPayload): Promise<AIModel[]>;
60
+ abstract listModels(params?: ModelSearchPayload): Promise<AIModel[]>;
61
61
  abstract listTrainableModels(): Promise<AIModel[]>;
62
62
  abstract validateConnection(): Promise<boolean>;
63
63
  abstract generateEmbeddings(content: string, model?: string): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"Driver.d.ts","sourceRoot":"","sources":["../../src/Driver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACH,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACN,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,aAAa,EACb,WAAW,EACX,eAAe,EACf,qBAAqB,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,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;KAAE,CAAC;CAElH"}
@@ -1,5 +1,10 @@
1
+ import type { ServerSentEvent } from "api-fetch-client";
1
2
  export declare function asyncMap<T, R>(asyncIterable: AsyncIterable<T>, callback: (value: T, index: number) => R): AsyncGenerator<Awaited<R>, void, unknown>;
2
3
  export declare function oneAsyncIterator<T>(value: T): AsyncIterable<T>;
4
+ /**
5
+ * Given a ReadableStream of server seent events, tran
6
+ */
7
+ export declare function transformSSEStream(stream: ReadableStream<ServerSentEvent>, transform: (data: string) => string): ReadableStream<string> & AsyncIterable<string>;
3
8
  export declare class EventStream<T, ReturnT = any> implements AsyncIterable<T> {
4
9
  private queue;
5
10
  private pending?;
@@ -1 +1 @@
1
- {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/async.ts"],"names":[],"mappings":"AACA,wBAAuB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,6CAI9G;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAM9D;AAGD,qBAAa,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,GAAG,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAElE,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,OAAO,CAAC,CAGd;IACF,OAAO,CAAC,IAAI,CAAS;IAGrB,IAAI,CAAC,KAAK,EAAE,CAAC;IAYb;;;OAGG;IACH,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO;IAQrB,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CA0BlE;AAID;;;;I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AAC,EAAE,CAAC,EAC9C,iBAAiB,EAAE,aAAa,CAAC,CAAC,CAAC,EACnC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACxC,aAAa,CAAC,CAAC,CAAC,CAIlB"}
@@ -0,0 +1,19 @@
1
+ import { JSONSchema4 } from "json-schema";
2
+ import { PromptSegment } from "../index.js";
3
+ export interface ClaudeMessage {
4
+ role: 'user' | 'assistant';
5
+ content: {
6
+ type: "image" | "text";
7
+ source?: string;
8
+ text?: string;
9
+ }[];
10
+ }
11
+ export interface ClaudeMessagesPrompt {
12
+ system?: string;
13
+ messages: ClaudeMessage[];
14
+ }
15
+ /**
16
+ * A formatter user by Bedrock to format prompts for claude related models
17
+ */
18
+ export declare function claudeMessages(segments: PromptSegment[], schema?: JSONSchema4): ClaudeMessagesPrompt;
19
+ //# sourceMappingURL=claude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../../src/formatters/claude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAc,aAAa,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE;QACL,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAA;KAChB,EAAE,CAAA;CACN;AAED,MAAM,WAAW,oBAAoB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,aAAa,EAAE,CAAA;CAC5B;AAED;;GAEG;AAEH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,oBAAoB,CA0CpG"}
@@ -0,0 +1,8 @@
1
+ import { JSONSchema4 } from "json-schema";
2
+ import { PromptSegment } from "../index.js";
3
+ export declare function genericColonSeparator(messages: PromptSegment[], schema?: JSONSchema4, labels?: {
4
+ user: string;
5
+ assistant: string;
6
+ system: string;
7
+ }): string;
8
+ //# sourceMappingURL=generic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../../src/formatters/generic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAc,aAAa,EAAE,MAAM,aAAa,CAAC;AAExD,wBAAgB,qBAAqB,CACjC,QAAQ,EAAE,aAAa,EAAE,EACzB,MAAM,CAAC,EAAE,WAAW,EACpB,MAAM,GAAE;IACJ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAC2C,UAuBjE"}
@@ -1,5 +1,5 @@
1
1
  import { JSONSchema4 } from "json-schema";
2
- import { PromptFormats, PromptSegment } from "./types.js";
2
+ import { PromptFormats, PromptSegment } from "../types.js";
3
3
  export declare function inferFormatterFromModelName(modelName: string): PromptFormats;
4
4
  export declare const PromptFormatters: Record<PromptFormats, (messages: PromptSegment[], schema?: JSONSchema4) => any>;
5
- //# sourceMappingURL=formatters.d.ts.map
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formatters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,OAAO,EACH,aAAa,EACb,aAAa,EAChB,MAAM,aAAa,CAAC;AAGrB,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CAW5E;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACjC,aAAa,EACb,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,MAAM,CAAC,EAAE,WAAW,KAAK,GAAG,CAM3D,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { JSONSchema4 } from "json-schema";
2
+ import { PromptSegment } from "../index.js";
3
+ export declare function llama2(messages: PromptSegment[], schema?: JSONSchema4): string;
4
+ //# sourceMappingURL=llama2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llama2.d.ts","sourceRoot":"","sources":["../../../src/formatters/llama2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAc,aAAa,EAAE,MAAM,aAAa,CAAC;AAExD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,MAAM,CAAC,EAAE,WAAW,UA2CrE"}
@@ -0,0 +1,4 @@
1
+ import { PromptSegment } from "../types.js";
2
+ import OpenAI from "openai";
3
+ export declare function openAI(segments: PromptSegment[]): OpenAI.Chat.Completions.ChatCompletionMessageParam[];
4
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/formatters/openai.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,wBAAgB,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,wDAiB/C"}
@@ -1,5 +1,5 @@
1
1
  export * from "./Driver.js";
2
- export * from "./formatters.js";
2
+ export * from "./formatters/index.js";
3
3
  export * from "./json.js";
4
4
  export * from "./types.js";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
@@ -10,7 +10,6 @@ export interface ResultValidationError {
10
10
  export interface Completion<ResultT = any> {
11
11
  result: ResultT;
12
12
  token_usage?: ExecutionTokenUsage;
13
- execution_time?: number;
14
13
  /**
15
14
  * Set only if a result validation error occured, otherwise if the result is valid the error field is undefined
16
15
  * This can only be set if the resultSchema is set and the reuslt could not be parsed as a json or if the result does not match the schema
@@ -19,6 +18,10 @@ export interface Completion<ResultT = any> {
19
18
  }
20
19
  export interface ExecutionResponse<PromptT = any> extends Completion {
21
20
  prompt: PromptT;
21
+ /**
22
+ * The time it took to execute the request in seconds
23
+ */
24
+ execution_time?: number;
22
25
  }
23
26
  export interface CompletionStream<PromptT = any> extends AsyncIterable<string> {
24
27
  completion: ExecutionResponse<PromptT> | undefined;
@@ -120,7 +123,8 @@ export declare enum BuiltinProviders {
120
123
  replicate = "replicate",
121
124
  bedrock = "bedrock",
122
125
  vertexai = "vertexai",
123
- togetherai = "togetherai"
126
+ togetherai = "togetherai",
127
+ mistralai = "mistralai"
124
128
  }
125
129
  export interface DataSource {
126
130
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,kBAAkB,GAAG,YAAY,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU,CAAC,OAAO,GAAG,GAAG;IAErC,MAAM,EAA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"module",
5
5
  "description": "Provide an universal API to LLMs. Support for existing LLMs can be added by writing a driver.",
6
6
  "files": [
@@ -64,6 +64,7 @@
64
64
  "devDependencies": {
65
65
  "@types/eventsource": "^1.1.15",
66
66
  "@types/json-schema": "^7.0.15",
67
+ "api-fetch-client": "^0.8.6",
67
68
  "ts-dual-module": "^0.6.2",
68
69
  "typescript": "^5.3.3",
69
70
  "vitest": "^1.2.2"
package/src/Driver.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { DefaultCompletionStream, FallbackCompletionStream } from "./CompletionStream.js";
8
- import { PromptFormatters } from "./formatters.js";
8
+ import { PromptFormatters } from "./formatters/index.js";
9
9
  import {
10
10
  AIModel,
11
11
  Completion,
@@ -196,7 +196,7 @@ export abstract class AbstractDriver<OptionsT extends DriverOptions = DriverOpti
196
196
  abstract requestCompletionStream(prompt: PromptT, options: ExecutionOptions): Promise<AsyncIterable<string>>;
197
197
 
198
198
  //list models available for this environement
199
- abstract listModels(params: ModelSearchPayload): Promise<AIModel[]>;
199
+ abstract listModels(params?: ModelSearchPayload): Promise<AIModel[]>;
200
200
 
201
201
  abstract listTrainableModels(): Promise<AIModel[]>;
202
202
 
package/src/async.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ServerSentEvent } from "api-fetch-client";
1
2
 
2
3
  export async function* asyncMap<T, R>(asyncIterable: AsyncIterable<T>, callback: (value: T, index: number) => R) {
3
4
  let i = 0;
@@ -13,6 +14,24 @@ export function oneAsyncIterator<T>(value: T): AsyncIterable<T> {
13
14
  }
14
15
  }
15
16
 
17
+ /**
18
+ * Given a ReadableStream of server seent events, tran
19
+ */
20
+ export function transformSSEStream(stream: ReadableStream<ServerSentEvent>, transform: (data: string) => string): ReadableStream<string> & AsyncIterable<string> {
21
+ // on node and bun the readablestream is an async iterable
22
+ return stream.pipeThrough(new TransformStream<ServerSentEvent, string>({
23
+ transform(event: ServerSentEvent, controller) {
24
+ if (event.type === 'event' && event.data && event.data !== '[DONE]') {
25
+ try {
26
+ controller.enqueue(transform(event.data) ?? '');
27
+ } catch (err) {
28
+ // double check for the last event whicb is not a JSON - at this time togetherai and mistralai returrns the string [DONE]
29
+ // do nothing - happens if data is not a JSON - the last event data is the [DONE] string
30
+ }
31
+ }
32
+ }
33
+ })) as ReadableStream<string> & AsyncIterable<string>;
34
+ }
16
35
 
17
36
  export class EventStream<T, ReturnT = any> implements AsyncIterable<T>{
18
37
 
@@ -0,0 +1,74 @@
1
+ import { JSONSchema4 } from "json-schema";
2
+ import { PromptRole, PromptSegment } from "../index.js";
3
+
4
+ export interface ClaudeMessage {
5
+ role: 'user' | 'assistant',
6
+ content: {
7
+ type: "image" | "text",
8
+ source?: string, // only set for images
9
+ text?: string // only set for text messages
10
+ }[]
11
+ }
12
+
13
+ export interface ClaudeMessagesPrompt {
14
+ system?: string;
15
+ messages: ClaudeMessage[]
16
+ }
17
+
18
+ /**
19
+ * A formatter user by Bedrock to format prompts for claude related models
20
+ */
21
+
22
+ export function claudeMessages(segments: PromptSegment[], schema?: JSONSchema4): ClaudeMessagesPrompt {
23
+ const system: string[] = [];
24
+ const safety: string[] = [];
25
+ const messages: ClaudeMessage[] = [];
26
+
27
+ for (const msg of segments) {
28
+ if (msg.role === PromptRole.system) {
29
+ system.push(msg.content);
30
+ } else if (msg.role === PromptRole.safety) {
31
+ safety.push(msg.content);
32
+ } else {
33
+ messages.push({ content: [{ type: "text", text: msg.content }], role: msg.role });
34
+ }
35
+ }
36
+
37
+ if (schema) {
38
+ safety.push(`You must answer using the following JSONSchema:
39
+ ---
40
+ ${JSON.stringify(schema)}
41
+ ---`);
42
+ }
43
+
44
+
45
+ // messages must contains at least 1 item. If the prompt doesn;t contains a user message (but only system messages)
46
+ // we need to put the system messages in the messages array
47
+
48
+ let systemMessage = system.join('\n').trim();
49
+ if (messages.length === 0) {
50
+ if (!systemMessage) {
51
+ throw new Error('Prompt must contain at least one message');
52
+ }
53
+ messages.push({ content: [{ type: "text", text: systemMessage }], role: 'user' });
54
+ systemMessage = safety.join('\n');
55
+ } else if (safety.length > 0) {
56
+ systemMessage = systemMessage + '\n\nIMPORTANT: ' + safety.join('\n');
57
+ }
58
+
59
+ // put system mesages first and safety last
60
+ return {
61
+ system: systemMessage,
62
+ messages
63
+ }
64
+ }
65
+
66
+ // export function claude(messages: PromptSegment[], schema?: JSONSchema4) {
67
+ // const prompt = genericColonSeparator(messages, schema, {
68
+ // user: "\nHuman",
69
+ // assistant: "\nAssistant",
70
+ // system: "\nHuman",
71
+ // });
72
+
73
+ // return "\n\n" + prompt + "\n\nAssistant:";
74
+ // }
@@ -0,0 +1,34 @@
1
+ import { JSONSchema4 } from "json-schema";
2
+ import { PromptRole, PromptSegment } from "../index.js";
3
+
4
+ export function genericColonSeparator(
5
+ messages: PromptSegment[],
6
+ schema?: JSONSchema4,
7
+ labels: {
8
+ user: string;
9
+ assistant: string;
10
+ system: string;
11
+ } = { user: "User", assistant: "Assistant", system: "System" }
12
+ ) {
13
+ const promptMessages = [];
14
+ for (const m of messages) {
15
+ if (m.role === PromptRole.user) {
16
+ promptMessages.push(`${labels?.user}: ${m.content.trim()}`);
17
+ }
18
+ if (m.role === PromptRole.assistant) {
19
+ promptMessages.push(`${labels.assistant}: ${m.content.trim()}`);
20
+ }
21
+ if (m.role === PromptRole.system) {
22
+ promptMessages.push(`${labels.system}: ${m.content.trim()}`);
23
+ }
24
+ }
25
+
26
+ if (schema) {
27
+ promptMessages.push(`${labels.system}: You must answer using the following JSONSchema:
28
+ ---
29
+ ${JSON.stringify(schema)}
30
+ ---`);
31
+ }
32
+
33
+ return promptMessages.join("\n\n");
34
+ }
@@ -0,0 +1,33 @@
1
+ import { JSONSchema4 } from "json-schema";
2
+ import { genericColonSeparator } from "./generic.js";
3
+ import { llama2 } from "./llama2.js";
4
+ import { openAI } from "./openai.js";
5
+ import {
6
+ PromptFormats,
7
+ PromptSegment
8
+ } from "../types.js";
9
+ import { claudeMessages } from "./claude.js";
10
+
11
+ export function inferFormatterFromModelName(modelName: string): PromptFormats {
12
+ const name = modelName.toLowerCase();
13
+ if (name.includes("llama")) {
14
+ return PromptFormats.llama2;
15
+ } else if (name.includes("gpt")) {
16
+ return PromptFormats.openai;
17
+ } else if (name.includes("claude")) {
18
+ return PromptFormats.claude;
19
+ } else {
20
+ return PromptFormats.genericTextLLM;
21
+ }
22
+ }
23
+
24
+ export const PromptFormatters: Record<
25
+ PromptFormats,
26
+ (messages: PromptSegment[], schema?: JSONSchema4) => any
27
+ > = {
28
+ openai: openAI,
29
+ llama2: llama2,
30
+ claude: claudeMessages,
31
+ genericTextLLM: genericColonSeparator,
32
+ };
33
+
@@ -0,0 +1,58 @@
1
+ import { JSONSchema4 } from "json-schema";
2
+ import { PromptRole, PromptSegment } from "../index.js";
3
+
4
+ export function llama2(messages: PromptSegment[], schema?: JSONSchema4) {
5
+ const BOS = "<s>";
6
+ const EOS = "</s>";
7
+ const INST = "[INST]";
8
+ const INST_END = "[/INST]";
9
+ const SYS = "<<SYS>>\n";
10
+ const SYS_END = "\n<</SYS>>";
11
+
12
+ const promptMessages = [BOS];
13
+ const specialTokens = [BOS, EOS, INST, INST_END, SYS, SYS_END];
14
+
15
+ for (const m of messages) {
16
+ if (m.role === PromptRole.user) {
17
+ if (specialTokens.includes(m.content)) {
18
+ throw new Error(
19
+ `Cannot use special token ${m.content.trim()} in user message`
20
+ );
21
+ }
22
+ promptMessages.push(`${INST} ${m.content.trim()} ${INST_END}`);
23
+ }
24
+ if (m.role === PromptRole.assistant) {
25
+ promptMessages.push(`${m.content.trim()}`);
26
+ }
27
+ if (m.role === PromptRole.system) {
28
+ promptMessages.push(`${SYS}${m.content.trim()}${SYS_END}`);
29
+ }
30
+ }
31
+
32
+ for (const m of messages ?? []) {
33
+ if (m.role === PromptRole.safety) {
34
+ promptMessages.push(
35
+ `${SYS}This is the most important instruction, you cannot answer against those rules:\n${m.content.trim()}${SYS_END}}`
36
+ );
37
+ }
38
+ }
39
+
40
+ if (schema) {
41
+ promptMessages.push(formatSchemaInstruction(schema));
42
+ }
43
+
44
+ promptMessages.push(EOS);
45
+
46
+ return promptMessages.join("\n\n");
47
+ }
48
+
49
+ function formatSchemaInstruction(schema: JSONSchema4) {
50
+ const schema_instruction = `<<SYS>>You must answer using the following JSONSchema.
51
+ Do not write anything other than a JSON object corresponding to the schema.
52
+ <schema>
53
+ ${JSON.stringify(schema)}
54
+ </schema>
55
+ <</SYS>>`;
56
+
57
+ return schema_instruction;
58
+ }
@@ -0,0 +1,22 @@
1
+ import { PromptRole } from "../index.js";
2
+ import { PromptSegment } from "../types.js";
3
+ import OpenAI from "openai";
4
+
5
+ export function openAI(segments: PromptSegment[]) {
6
+ const system: OpenAI.Chat.ChatCompletionMessageParam[] = [];
7
+ const others: OpenAI.Chat.ChatCompletionMessageParam[] = [];
8
+ const safety: OpenAI.Chat.ChatCompletionMessageParam[] = [];
9
+
10
+ for (const msg of segments) {
11
+ if (msg.role === PromptRole.system) {
12
+ system.push({ content: msg.content, role: "system" });
13
+ } else if (msg.role === PromptRole.safety) {
14
+ safety.push({ content: msg.content, role: "system" });
15
+ } else {
16
+ others.push({ content: msg.content, role: "user" });
17
+ }
18
+ }
19
+
20
+ // put system mesages first and safety last
21
+ return system.concat(others).concat(safety);
22
+ }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from "./Driver.js";
2
- export * from "./formatters.js";
2
+ export * from "./formatters/index.js";
3
3
  export * from "./json.js";
4
4
  export * from "./types.js";
package/src/types.ts CHANGED
@@ -12,7 +12,7 @@ export interface Completion<ResultT = any> {
12
12
  // the driver impl must return the result and optionally the token_usage. the execution time is computed by the extended abstract driver
13
13
  result: ResultT;
14
14
  token_usage?: ExecutionTokenUsage;
15
- execution_time?: number;
15
+
16
16
  /**
17
17
  * Set only if a result validation error occured, otherwise if the result is valid the error field is undefined
18
18
  * This can only be set if the resultSchema is set and the reuslt could not be parsed as a json or if the result does not match the schema
@@ -22,6 +22,10 @@ export interface Completion<ResultT = any> {
22
22
 
23
23
  export interface ExecutionResponse<PromptT = any> extends Completion {
24
24
  prompt: PromptT;
25
+ /**
26
+ * The time it took to execute the request in seconds
27
+ */
28
+ execution_time?: number;
25
29
  }
26
30
 
27
31
 
@@ -146,6 +150,7 @@ export enum BuiltinProviders {
146
150
  bedrock = 'bedrock',
147
151
  vertexai = 'vertexai',
148
152
  togetherai = 'togetherai',
153
+ mistralai = 'mistralai',
149
154
  //virtual = 'virtual',
150
155
  //cohere = 'cohere',
151
156
  }
@@ -1,117 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PromptFormatters = exports.inferFormatterFromModelName = void 0;
4
- const types_js_1 = require("./types.js");
5
- function inferFormatterFromModelName(modelName) {
6
- const name = modelName.toLowerCase();
7
- if (name.includes("llama")) {
8
- return types_js_1.PromptFormats.llama2;
9
- }
10
- else if (name.includes("gpt")) {
11
- return types_js_1.PromptFormats.openai;
12
- }
13
- else if (name.includes("claude")) {
14
- return types_js_1.PromptFormats.claude;
15
- }
16
- else {
17
- return types_js_1.PromptFormats.genericTextLLM;
18
- }
19
- }
20
- exports.inferFormatterFromModelName = inferFormatterFromModelName;
21
- exports.PromptFormatters = {
22
- openai: openAI,
23
- llama2: llama2,
24
- claude: claude,
25
- genericTextLLM: genericColonSeparator,
26
- };
27
- function openAI(segments) {
28
- const system = [];
29
- const others = [];
30
- const safety = [];
31
- for (const msg of segments) {
32
- if (msg.role === types_js_1.PromptRole.system) {
33
- system.push({ content: msg.content, role: "system" });
34
- }
35
- else if (msg.role === types_js_1.PromptRole.safety) {
36
- safety.push({ content: msg.content, role: "system" });
37
- }
38
- else {
39
- others.push({ content: msg.content, role: "user" });
40
- }
41
- }
42
- // put system mesages first and safety last
43
- return system.concat(others).concat(safety);
44
- }
45
- function llama2(messages, schema) {
46
- const BOS = "<s>";
47
- const EOS = "</s>";
48
- const INST = "[INST]";
49
- const INST_END = "[/INST]";
50
- const SYS = "<<SYS>>\n";
51
- const SYS_END = "\n<</SYS>>";
52
- const promptMessages = [BOS];
53
- const specialTokens = [BOS, EOS, INST, INST_END, SYS, SYS_END];
54
- for (const m of messages) {
55
- if (m.role === types_js_1.PromptRole.user) {
56
- if (specialTokens.includes(m.content)) {
57
- throw new Error(`Cannot use special token ${m.content.trim()} in user message`);
58
- }
59
- promptMessages.push(`${INST} ${m.content.trim()} ${INST_END}`);
60
- }
61
- if (m.role === types_js_1.PromptRole.assistant) {
62
- promptMessages.push(`${m.content.trim()}`);
63
- }
64
- if (m.role === types_js_1.PromptRole.system) {
65
- promptMessages.push(`${SYS}${m.content.trim()}${SYS_END}`);
66
- }
67
- }
68
- for (const m of messages ?? []) {
69
- if (m.role === types_js_1.PromptRole.safety) {
70
- promptMessages.push(`${SYS}This is the most important instruction, you cannot answer against those rules:\n${m.content.trim()}${SYS_END}}`);
71
- }
72
- }
73
- if (schema) {
74
- promptMessages.push(formatSchemaInstruction(schema));
75
- }
76
- promptMessages.push(EOS);
77
- return promptMessages.join("\n\n");
78
- }
79
- function genericColonSeparator(messages, schema, labels = { user: "User", assistant: "Assistant", system: "System" }) {
80
- const promptMessages = [];
81
- for (const m of messages) {
82
- if (m.role === types_js_1.PromptRole.user) {
83
- promptMessages.push(`${labels?.user}: ${m.content.trim()}`);
84
- }
85
- if (m.role === types_js_1.PromptRole.assistant) {
86
- promptMessages.push(`${labels.assistant}: ${m.content.trim()}`);
87
- }
88
- if (m.role === types_js_1.PromptRole.system) {
89
- promptMessages.push(`${labels.system}: ${m.content.trim()}`);
90
- }
91
- }
92
- if (schema) {
93
- promptMessages.push(`${labels.system}: You must answer using the following JSONSchema:
94
- ---
95
- ${JSON.stringify(schema)}
96
- ---`);
97
- }
98
- return promptMessages.join("\n\n");
99
- }
100
- function claude(messages, schema) {
101
- const prompt = genericColonSeparator(messages, schema, {
102
- user: "\nHuman",
103
- assistant: "\nAssistant",
104
- system: "\nHuman",
105
- });
106
- return "\n\n" + prompt + "\n\nAssistant:";
107
- }
108
- function formatSchemaInstruction(schema) {
109
- const schema_instruction = `<<SYS>>You must answer using the following JSONSchema.
110
- Do not write anything other than a JSON object corresponding to the schema.
111
- <schema>
112
- ${JSON.stringify(schema)}
113
- </schema>
114
- <</SYS>>`;
115
- return schema_instruction;
116
- }
117
- //# sourceMappingURL=formatters.js.map