simple-agents-node 0.2.2 → 0.2.3

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
@@ -14,11 +14,32 @@ npm run build
14
14
  ```javascript
15
15
  const { Client } = require('./index.js');
16
16
 
17
- const client = new Client('openai');
17
+ const provider = process.env.PROVIDER;
18
+ const model = process.env.CUSTOM_API_MODEL;
19
+ const key = process.env.CUSTOM_API_KEY;
20
+ const base = process.env.CUSTOM_API_BASE;
21
+
22
+ if (!provider || !model || !key) {
23
+ throw new Error('Set PROVIDER, CUSTOM_API_KEY, and CUSTOM_API_MODEL.');
24
+ }
25
+
26
+ if (provider === 'openai') {
27
+ process.env.OPENAI_API_KEY = key;
28
+ if (base) process.env.OPENAI_API_BASE = base;
29
+ }
30
+ if (provider === 'anthropic') {
31
+ process.env.ANTHROPIC_API_KEY = key;
32
+ }
33
+ if (provider === 'openrouter') {
34
+ process.env.OPENROUTER_API_KEY = key;
35
+ if (base) process.env.OPENROUTER_API_BASE = base;
36
+ }
37
+
38
+ const client = new Client(provider);
18
39
 
19
40
  async function main() {
20
41
  const response = await client.complete(
21
- 'gpt-4',
42
+ model,
22
43
  [
23
44
  { role: 'system', content: 'You are concise.' },
24
45
  { role: 'user', content: 'Say hi from Node.' },
@@ -32,13 +53,13 @@ async function main() {
32
53
 
33
54
  // Streaming
34
55
  const streamed = await client.stream(
35
- 'gpt-4',
56
+ model,
36
57
  'Say hello in two words.',
37
- {},
38
58
  (chunk) => {
39
59
  if (chunk.content) process.stdout.write(chunk.content);
40
60
  if (chunk.finish_reason) console.log('\nfinish:', chunk.finish_reason);
41
61
  },
62
+ {},
42
63
  );
43
64
  console.log('streamed content:', streamed.content);
44
65
 
package/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export interface CompleteOptions {
10
10
  stream?: boolean
11
11
  /** "standard" | "healed_json" | "schema" */
12
12
  mode?: string
13
- schema?: Schema
13
+ schema?: unknown
14
14
  }
15
15
  export interface MessageInput {
16
16
  role: string
@@ -62,5 +62,5 @@ export interface StreamChunk {
62
62
  export declare class Client {
63
63
  constructor(provider: string)
64
64
  complete(model: string, promptOrMessages: string | MessageInput[], options?: CompleteOptions): Promise<unknown>
65
- stream(model: string, promptOrMessages: string | MessageInput[], options?: CompleteOptions, onChunk: (chunk: StreamChunk) => void): Promise<unknown>
65
+ stream(model: string, promptOrMessages: string | MessageInput[], onChunk: (chunk: StreamChunk) => void, options?: CompleteOptions): Promise<unknown>
66
66
  }
package/index.node CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-agents-node",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Node.js bindings for SimpleAgents using napi-rs",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",