@apicity/fireworks 0.1.0-alpha.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.
@@ -0,0 +1,8 @@
1
+ export interface EndpointExample {
2
+ source: string;
3
+ payload: unknown;
4
+ }
5
+ declare const EXAMPLES: Record<string, EndpointExample>;
6
+ export default EXAMPLES;
7
+ export declare function attachExamples<T>(provider: T): T;
8
+ //# sourceMappingURL=example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/example.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,QAAA,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CA0D7C,CAAC;AAEF,eAAe,QAAQ,CAAC;AAOxB,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CA6ChD"}
@@ -0,0 +1,143 @@
1
+ // Auto-generated by `pnpm run gen:examples` — do not edit by hand.
2
+ // Source: tests/recordings/<provider>_*/<test>_*/recording.har
3
+ //
4
+ // Each entry is the green-path payload for one endpoint, mined from a real
5
+ // integration-test recording. `attachExamples` walks the provider tree and
6
+ // hangs the matching entry off each endpoint function as `.example`.
7
+ const EXAMPLES = {
8
+ "POST inference.v1.chat.completions": {
9
+ "source": "fireworks/chat-hello",
10
+ "payload": {
11
+ "model": "accounts/fireworks/models/llama-v3p3-70b-instruct",
12
+ "messages": [
13
+ {
14
+ "role": "user",
15
+ "content": "Say hello in one sentence."
16
+ }
17
+ ],
18
+ "temperature": 0,
19
+ "max_tokens": 64
20
+ }
21
+ },
22
+ "POST inference.v1.completions": {
23
+ "source": "fireworks/completions-hello",
24
+ "payload": {
25
+ "model": "accounts/fireworks/models/llama-v3p3-70b-instruct",
26
+ "prompt": "The capital of France is",
27
+ "max_tokens": 32,
28
+ "temperature": 0
29
+ }
30
+ },
31
+ "POST inference.v1.embeddings": {
32
+ "source": "fireworks/embeddings-hello",
33
+ "payload": {
34
+ "model": "nomic-ai/nomic-embed-text-v1.5",
35
+ "input": "Hello world"
36
+ }
37
+ },
38
+ "POST inference.v1.messages": {
39
+ "source": "fireworks/messages-hello",
40
+ "payload": {
41
+ "model": "accounts/fireworks/models/llama-v3p3-70b-instruct",
42
+ "messages": [
43
+ {
44
+ "role": "user",
45
+ "content": "Say hello in one sentence."
46
+ }
47
+ ],
48
+ "max_tokens": 64
49
+ }
50
+ },
51
+ "POST inference.v1.rerank": {
52
+ "source": "fireworks/rerank-basic",
53
+ "payload": {
54
+ "model": "fireworks/qwen3-reranker-8b",
55
+ "query": "What is the capital of France?",
56
+ "documents": [
57
+ "Berlin is the capital of Germany.",
58
+ "Paris is the capital and largest city of France.",
59
+ "Madrid is the capital of Spain."
60
+ ],
61
+ "top_n": 2,
62
+ "return_documents": true
63
+ }
64
+ }
65
+ };
66
+ export default EXAMPLES;
67
+ // Walks each "<METHOD> <dotPath>" key onto the provider's tree. Tries the
68
+ // standard `provider.<method>.<dotPath>` shape first, then a few fallbacks
69
+ // to cover providers with non-standard layouts (fal's `.run.` namespace,
70
+ // kie's sub-providers, `free`'s flat root). Returns the same provider for
71
+ // drop-in use as `return attachExamples({ ... });`.
72
+ export function attachExamples(provider) {
73
+ const root = provider;
74
+ const HTTP_KEYS = new Set(["post", "get", "put", "delete", "patch", "head"]);
75
+ for (const [key, example] of Object.entries(EXAMPLES)) {
76
+ const sp = key.indexOf(" ");
77
+ if (sp < 0)
78
+ continue;
79
+ const method = key.slice(0, sp).toLowerCase();
80
+ const segs = key.slice(sp + 1).split(".");
81
+ const candidates = [
82
+ root[method],
83
+ root[method]?.run,
84
+ root,
85
+ ];
86
+ if (segs.length > 1) {
87
+ const sub = root[segs[0]];
88
+ if (sub && typeof sub === "object") {
89
+ const subMethod = sub[method];
90
+ if (subMethod)
91
+ candidates.push({ __nested: subMethod, __segs: segs.slice(1) });
92
+ }
93
+ }
94
+ let attached = false;
95
+ for (const c of candidates) {
96
+ const fn = walkToFn(c, segs);
97
+ if (fn) {
98
+ Object.assign(fn, { example });
99
+ attached = true;
100
+ break;
101
+ }
102
+ }
103
+ if (attached)
104
+ continue;
105
+ for (const k of Object.keys(root)) {
106
+ if (HTTP_KEYS.has(k))
107
+ continue;
108
+ if (!segs.includes(k))
109
+ continue;
110
+ const sub = root[k];
111
+ if (!sub || typeof sub !== "object")
112
+ continue;
113
+ const subMethod = sub[method];
114
+ if (!subMethod)
115
+ continue;
116
+ const fn = walkToFn(subMethod, segs);
117
+ if (fn) {
118
+ Object.assign(fn, { example });
119
+ break;
120
+ }
121
+ }
122
+ }
123
+ return provider;
124
+ }
125
+ function walkToFn(start, segs) {
126
+ if (start && typeof start === "object" && "__nested" in start) {
127
+ const wrapper = start;
128
+ return walkToFn(wrapper.__nested, wrapper.__segs);
129
+ }
130
+ let cur = start;
131
+ for (const seg of segs) {
132
+ if (cur === null || cur === undefined)
133
+ return null;
134
+ const t = typeof cur;
135
+ if (t !== "object" && t !== "function")
136
+ return null;
137
+ cur = cur[seg];
138
+ }
139
+ return typeof cur === "function"
140
+ ? cur
141
+ : null;
142
+ }
143
+ //# sourceMappingURL=example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.js","sourceRoot":"","sources":["../../src/example.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,+DAA+D;AAC/D,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,qEAAqE;AAOrE,MAAM,QAAQ,GAAoC;IAChD,oCAAoC,EAAE;QACpC,QAAQ,EAAE,sBAAsB;QAChC,SAAS,EAAE;YACT,OAAO,EAAE,mDAAmD;YAC5D,UAAU,EAAE;gBACV;oBACE,MAAM,EAAE,MAAM;oBACd,SAAS,EAAE,4BAA4B;iBACxC;aACF;YACD,aAAa,EAAE,CAAC;YAChB,YAAY,EAAE,EAAE;SACjB;KACF;IAC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AO,GAAG,KAAK,UAAU;QAC9B,CAAC,CAAE,GAAuC;QAC1C,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { FireworksOptions, FireworksProvider } from "./types";
2
+ export declare function fireworks(opts: FireworksOptions): FireworksProvider;
3
+ //# sourceMappingURL=fireworks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fireworks.d.ts","sourceRoot":"","sources":["../../src/fireworks.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAgJhB,iBAAiB,EAElB,MAAM,SAAS,CAAC;AAkEjB,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,iBAAiB,CA0/FnE"}