wirejs-resources 0.1.142-llm → 0.1.144-llm

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.
@@ -1,6 +1,6 @@
1
1
  import { Resource } from '../resource.js';
2
2
  export type LLMMessage = {
3
- role: 'assistant' | 'user' | 'system' | 'tool';
3
+ role: 'assistant' | 'user';
4
4
  content: string;
5
5
  };
6
6
  export type LLMChunk = {
@@ -10,8 +10,10 @@ export type LLMChunk = {
10
10
  };
11
11
  export declare class LLM extends Resource {
12
12
  models: string[];
13
+ systemPrompt: string | undefined;
13
14
  constructor(scope: Resource | string, id: string, options: {
14
15
  models: string[];
16
+ systemPrompt?: string;
15
17
  });
16
18
  private stream;
17
19
  private checkOllamaAvailable;
@@ -1,9 +1,11 @@
1
1
  import { Resource } from '../resource.js';
2
2
  export class LLM extends Resource {
3
3
  models;
4
+ systemPrompt;
4
5
  constructor(scope, id, options) {
5
6
  super(scope, id);
6
7
  this.models = options.models;
8
+ this.systemPrompt = options.systemPrompt;
7
9
  }
8
10
  async stream(response, onChunk) {
9
11
  if (!response.ok || !response.body) {
@@ -95,7 +97,15 @@ export class LLM extends Resource {
95
97
  headers: { 'Content-Type': 'application/json' },
96
98
  body: JSON.stringify({
97
99
  model: model,
98
- messages: [...history],
100
+ messages: [
101
+ ...(this.systemPrompt ? [
102
+ {
103
+ role: 'system',
104
+ content: this.systemPrompt
105
+ }
106
+ ] : []),
107
+ ...history
108
+ ],
99
109
  stream,
100
110
  })
101
111
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirejs-resources",
3
- "version": "0.1.142-llm",
3
+ "version": "0.1.144-llm",
4
4
  "description": "Basic services and server-side resources for wirejs apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",