@cognipeer/agent-sdk 0.10.5 → 0.12.0
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 +28 -3
- package/dist/index.cjs +1785 -501
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1073 -661
- package/dist/index.d.ts +1073 -661
- package/dist/index.mjs +1778 -501
- package/dist/index.mjs.map +1 -1
- package/package.json +39 -1
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ Highlights:
|
|
|
56
56
|
|
|
57
57
|
## Install
|
|
58
58
|
|
|
59
|
-
Install the SDK
|
|
59
|
+
Install the SDK. Every `@langchain/*` package (and `langchain`) is an *optional* peer dependency, nothing imports LangChain unless you use the LangChain adapters:
|
|
60
60
|
|
|
61
61
|
```sh
|
|
62
62
|
npm install @cognipeer/agent-sdk zod
|
|
@@ -104,15 +104,40 @@ createProvider({ provider: "anthropic", apiKey: process.env.ANTHROPIC_API_KEY! }
|
|
|
104
104
|
createProvider({ provider: "azure", apiKey: "...", endpoint: "https://my-resource.openai.azure.com", deploymentName: "gpt-4o" })
|
|
105
105
|
|
|
106
106
|
// AWS Bedrock
|
|
107
|
-
createProvider({ provider: "bedrock", region: "us-east-1", accessKeyId: "...", secretAccessKey: "..." })
|
|
107
|
+
createProvider({ provider: "bedrock", region: "us-east-1", accessKeyId: "...", secretAccessKey: "..." }) // streams via ConverseStream
|
|
108
108
|
|
|
109
109
|
// Google Vertex AI
|
|
110
|
-
createProvider({ provider: "vertex", projectId: "my-project", accessToken: process.env.VERTEX_TOKEN })
|
|
110
|
+
createProvider({ provider: "vertex", projectId: "my-project", accessToken: process.env.VERTEX_TOKEN }) // retry on 429/5xx, thoughtSignature round-trip; reasoning.thinkingLevel for Gemini 3
|
|
111
111
|
|
|
112
112
|
// Any OpenAI-compatible endpoint (Ollama, Groq, Together, vLLM, …)
|
|
113
113
|
createProvider({ provider: "openai-compatible", apiKey: "...", baseURL: "https://custom.endpoint/v1" })
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
+
### Embeddings
|
|
117
|
+
|
|
118
|
+
Every provider with an embeddings endpoint exposes `embed()`. It returns one vector per input, in order, plus token usage:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
const provider = createProvider({ provider: "openai", apiKey: process.env.OPENAI_API_KEY! });
|
|
122
|
+
const { vectors, usage } = await provider.embed({
|
|
123
|
+
model: "text-embedding-3-small",
|
|
124
|
+
input: ["first text", "second text"],
|
|
125
|
+
dimensions: 256, // models that support shortening
|
|
126
|
+
inputType: "search_query" // Cohere on Bedrock, task type on Vertex
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
| Provider | Endpoint | Notes |
|
|
131
|
+
| --- | --- | --- |
|
|
132
|
+
| `openai`, `openai-compatible` | `POST /embeddings` | batched (2048), `encodingFormat: "base64"` is decoded |
|
|
133
|
+
| `azure` | `/openai/deployments/{model}/embeddings` | `model` is the deployment name |
|
|
134
|
+
| `bedrock` | `InvokeModel` | Titan Text Embeddings v1/v2, Cohere Embed v3/v4 |
|
|
135
|
+
| `vertex` | `:predict` | text-embedding, multilingual, `gemini-embedding` |
|
|
136
|
+
|
|
137
|
+
### Gateway use
|
|
138
|
+
|
|
139
|
+
For hosts that front the providers with their own gateway: `ChatCompletionRequest` takes `streamUsage`, `seed`, `n`, `parallelToolCalls`, `logprobs` and `topLogprobs`; responses and stream chunks keep the provider's `rawFinishReason` and `providerFields` (`system_fingerprint`, `service_tier`, `annotations`, `refusal`, `logprobs`); streamed tool-call deltas carry an `index`. On Bedrock, `extra` keys that are not Converse request fields travel in `additionalModelRequestFields`.
|
|
140
|
+
|
|
116
141
|
### Smart agent (planning + summarization)
|
|
117
142
|
|
|
118
143
|
```ts
|