@glassly/llm-providers 0.4.3 → 0.4.4-dev.1305
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 +43 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @glassly/llm-providers
|
|
2
|
+
|
|
3
|
+
Vendor LLM adapters (Anthropic, Gemini, OpenAI, DeepSeek) behind one neutral `complete` call. The Glassly cloud Runtime uses them with the platform's keys, and the Glassly App uses the same code to call a vendor directly with a key the user saved. It is published to npm with the other Glassly packages ([`.github/release-family.json`](https://github.com/tetramo-labs/glassly/blob/dev/.github/release-family.json)) and lives in the [Cloud](https://github.com/tetramo-labs/glassly/tree/dev/cloud#readme) folder of the Glassly monorepo.
|
|
4
|
+
|
|
5
|
+
## Use
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @glassly/llm-providers
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import {createAnthropicProvider} from "@glassly/llm-providers";
|
|
13
|
+
|
|
14
|
+
const provider = createAnthropicProvider({defaultModel: "claude-sonnet-5"});
|
|
15
|
+
|
|
16
|
+
const result = await provider.complete({
|
|
17
|
+
apiKey,
|
|
18
|
+
messages: [{role: "user", content: "Say hello."}],
|
|
19
|
+
});
|
|
20
|
+
console.log(result.text, result.stopReason, result.usage);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
| Factory | Default model |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `createAnthropicProvider(options)` | `claude-sonnet-5` |
|
|
26
|
+
| `createGeminiProvider(options)` | `gemini-3.5-flash` |
|
|
27
|
+
| `createOpenAiProvider(options)` | `gpt-5.1` |
|
|
28
|
+
| `createDeepSeekProvider(options)` | `deepseek-chat` |
|
|
29
|
+
|
|
30
|
+
- Requests and results use the neutral types from [`@glassly/cloud-protocol/llm`](https://github.com/tetramo-labs/glassly/tree/dev/cloud/packages/protocol#readme): messages, tools, `jsonMode`, `webSearch`, stop reasons and token usage.
|
|
31
|
+
- `apiKey` is passed on every call, so the caller chooses between a platform key and a user's own key.
|
|
32
|
+
- `options.defaultModel` replaces the default model; `options.logger` receives errors and is silent when omitted.
|
|
33
|
+
- The package uses only global `fetch` and JSON, with no Node APIs and no environment reads, so it runs wherever `fetch` exists, including React Native.
|
|
34
|
+
- `complete` throws on transport and auth failures. A refusal or a tool-call pause returns a result with the matching `stopReason`.
|
|
35
|
+
|
|
36
|
+
## Test
|
|
37
|
+
|
|
38
|
+
From this folder: `bun test`. The tests stub `fetch` and need no network or keys. CI is dispatch-only (`Cloud Validation` runs `bun test packages`), so run them locally. From the repo root, [`bun run check`](https://github.com/tetramo-labs/glassly/blob/dev/AGENTS.md#whole-repo) runs `bun test packages` when your branch changes `cloud/`.
|
|
39
|
+
|
|
40
|
+
## More
|
|
41
|
+
|
|
42
|
+
- [Runtime LLM service](https://github.com/tetramo-labs/glassly/tree/dev/cloud/packages/runtime/src/services/llm/README.md): how Runtime picks a provider, resolves keys and meters calls
|
|
43
|
+
- [`@glassly/cloud-protocol`](https://github.com/tetramo-labs/glassly/tree/dev/cloud/packages/protocol#readme): the request and result schemas
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glassly/llm-providers",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4-dev.1305",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"test": "bun test"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@glassly/cloud-protocol": "0.4.
|
|
13
|
+
"@glassly/cloud-protocol": "0.4.4-dev.1305"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"src",
|