@modelrelay/sdk 5.1.0 → 5.3.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 +19 -64
- package/dist/api-7TVb2cnl.d.cts +5319 -0
- package/dist/api-7TVb2cnl.d.ts +5319 -0
- package/dist/api-B9x3HA3Z.d.cts +5292 -0
- package/dist/api-B9x3HA3Z.d.ts +5292 -0
- package/dist/{api-c1j5ycVR.d.cts → api-BRAJe_xm.d.cts} +54 -0
- package/dist/{api-c1j5ycVR.d.ts → api-BRAJe_xm.d.ts} +54 -0
- package/dist/api-Bitsm1tl.d.cts +5290 -0
- package/dist/api-Bitsm1tl.d.ts +5290 -0
- package/dist/api-D0wnVpwn.d.cts +5292 -0
- package/dist/api-D0wnVpwn.d.ts +5292 -0
- package/dist/api-HVh8Lusf.d.cts +5300 -0
- package/dist/api-HVh8Lusf.d.ts +5300 -0
- package/dist/billing/index.d.cts +1 -1
- package/dist/billing/index.d.ts +1 -1
- package/dist/{chunk-RVHKBQ7X.js → chunk-5O4NJXLJ.js} +1 -1
- package/dist/chunk-BL7GWXRZ.js +1196 -0
- package/dist/chunk-CV3DTA6P.js +1196 -0
- package/dist/chunk-G5H7EY4F.js +1196 -0
- package/dist/chunk-HLJAMT7F.js +1133 -0
- package/dist/chunk-JZRSCFQH.js +1133 -0
- package/dist/chunk-LZDGY24E.js +1133 -0
- package/dist/chunk-OJFVI3QJ.js +1133 -0
- package/dist/chunk-Z6R4G2TU.js +1133 -0
- package/dist/index.cjs +54 -2
- package/dist/index.d.cts +58 -2
- package/dist/index.d.ts +58 -2
- package/dist/index.js +51 -2
- package/dist/node.cjs +1 -1
- package/dist/node.js +1 -1
- package/dist/tools-Db-F5rIL.d.cts +1169 -0
- package/dist/tools-Db-F5rIL.d.ts +1169 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,80 +98,35 @@ const text = await mr.responses.textForCustomer({
|
|
|
98
98
|
|
|
99
99
|
## Workflows
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
Build multi-step AI pipelines with the workflow helpers.
|
|
102
102
|
|
|
103
|
-
### Chain
|
|
104
|
-
|
|
105
|
-
Sequential LLM calls where each step's output feeds the next step's input:
|
|
103
|
+
### Sequential Chain
|
|
106
104
|
|
|
107
105
|
```ts
|
|
108
|
-
import { chain,
|
|
106
|
+
import { chain, llm } from "@modelrelay/sdk";
|
|
109
107
|
|
|
110
|
-
const
|
|
111
|
-
.
|
|
112
|
-
.
|
|
113
|
-
|
|
114
|
-
.
|
|
115
|
-
.build();
|
|
116
|
-
|
|
117
|
-
const translateReq = mr.responses
|
|
118
|
-
.new()
|
|
119
|
-
.model("claude-sonnet-4-5")
|
|
120
|
-
.system("Translate the input to French.")
|
|
121
|
-
.user("") // Bound from previous step
|
|
108
|
+
const spec = chain([
|
|
109
|
+
llm("summarize", (n) => n.system("Summarize.").user("{{task}}")),
|
|
110
|
+
llm("translate", (n) => n.system("Translate to French.").user("{{summarize}}")),
|
|
111
|
+
], { name: "summarize-translate", model: "claude-sonnet-4-5" })
|
|
112
|
+
.output("result", "translate")
|
|
122
113
|
.build();
|
|
123
114
|
|
|
124
|
-
const
|
|
125
|
-
.step(llmStep("summarize", summarizeReq))
|
|
126
|
-
.step(llmStep("translate", translateReq).withStream())
|
|
127
|
-
.outputLast("result")
|
|
128
|
-
.build();
|
|
115
|
+
const { run_id } = await mr.runs.create(spec);
|
|
129
116
|
```
|
|
130
117
|
|
|
131
|
-
### Parallel
|
|
132
|
-
|
|
133
|
-
Concurrent LLM calls with optional aggregation:
|
|
118
|
+
### Parallel with Aggregation
|
|
134
119
|
|
|
135
120
|
```ts
|
|
136
|
-
import { parallel,
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.
|
|
143
|
-
.
|
|
144
|
-
.
|
|
145
|
-
.build();
|
|
146
|
-
|
|
147
|
-
const spec = parallel("multi-model-compare")
|
|
148
|
-
.step(llmStep("gpt4", gpt4Req))
|
|
149
|
-
.step(llmStep("claude", claudeReq))
|
|
150
|
-
.aggregate("synthesize", synthesizeReq)
|
|
151
|
-
.output("result", "synthesize")
|
|
152
|
-
.build();
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### MapReduce (Parallel Map with Reduce)
|
|
156
|
-
|
|
157
|
-
Process items in parallel, then combine results:
|
|
158
|
-
|
|
159
|
-
```ts
|
|
160
|
-
import { mapReduce } from "@modelrelay/sdk";
|
|
161
|
-
|
|
162
|
-
const combineReq = mr.responses
|
|
163
|
-
.new()
|
|
164
|
-
.model("claude-sonnet-4-5")
|
|
165
|
-
.system("Combine summaries into a cohesive overview.")
|
|
166
|
-
.user("") // Bound from join output
|
|
167
|
-
.build();
|
|
168
|
-
|
|
169
|
-
const spec = mapReduce("summarize-docs")
|
|
170
|
-
.item("doc1", doc1Req)
|
|
171
|
-
.item("doc2", doc2Req)
|
|
172
|
-
.item("doc3", doc3Req)
|
|
173
|
-
.reduce("combine", combineReq)
|
|
174
|
-
.output("result", "combine")
|
|
121
|
+
import { parallel, llm } from "@modelrelay/sdk";
|
|
122
|
+
|
|
123
|
+
const spec = parallel([
|
|
124
|
+
llm("agent_a", (n) => n.user("Write 3 ideas for {{task}}.")),
|
|
125
|
+
llm("agent_b", (n) => n.user("Write 3 objections for {{task}}.")),
|
|
126
|
+
], { name: "multi-agent", model: "claude-sonnet-4-5" })
|
|
127
|
+
.llm("aggregate", (n) => n.system("Synthesize.").user("{{join}}"))
|
|
128
|
+
.edge("join", "aggregate")
|
|
129
|
+
.output("result", "aggregate")
|
|
175
130
|
.build();
|
|
176
131
|
```
|
|
177
132
|
|