@llmops/sdk 0.1.0-beta.10 → 0.1.0-beta.11

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,35 @@
1
+ let node_stream = require("node:stream");
2
+
3
+ //#region src/lib/express/index.ts
4
+ function createLLMOpsMiddleware(client) {
5
+ const basePath = client.config.basePath;
6
+ return async (req, res, next) => {
7
+ let urlPath = req.originalUrl;
8
+ if (basePath && urlPath.startsWith(basePath)) urlPath = urlPath.slice(basePath.length) || "/";
9
+ const url = new URL(urlPath, `${req.protocol}://${req.get("host")}`);
10
+ const request = new Request(url, {
11
+ method: req.method,
12
+ headers: req.headers,
13
+ body: ["GET", "HEAD"].includes(req.method) ? void 0 : JSON.stringify(req.body)
14
+ });
15
+ const response = await client.handler(request);
16
+ if (response.status === 404) return next();
17
+ response.headers?.forEach((value, key) => {
18
+ res.setHeader(key, value);
19
+ });
20
+ res.status(response.status);
21
+ if ((response.headers?.get("content-type"))?.includes("text/event-stream") && response.body) node_stream.Readable.fromWeb(response.body).pipe(res);
22
+ else {
23
+ const body = await response.text();
24
+ res.send(body);
25
+ }
26
+ };
27
+ }
28
+
29
+ //#endregion
30
+ Object.defineProperty(exports, 'createLLMOpsMiddleware', {
31
+ enumerable: true,
32
+ get: function () {
33
+ return createLLMOpsMiddleware;
34
+ }
35
+ });
@@ -0,0 +1,3 @@
1
+ const require_express = require('./express-B-wbCza5.cjs');
2
+
3
+ exports.createLLMOpsMiddleware = require_express.createLLMOpsMiddleware;
@@ -0,0 +1,3 @@
1
+ import "./index-fafxrrPF.cjs";
2
+ import { t as createLLMOpsMiddleware } from "./index-UQjBf1t7.cjs";
3
+ export { createLLMOpsMiddleware };
package/dist/hono.cjs ADDED
@@ -0,0 +1,31 @@
1
+
2
+ //#region src/lib/hono/index.ts
3
+ function createLLMOpsMiddleware(client) {
4
+ const basePath = client.config.basePath;
5
+ return async (c, next) => {
6
+ let urlPath = c.req.path;
7
+ if (basePath && urlPath.startsWith(basePath)) urlPath = urlPath.slice(basePath.length) || "/";
8
+ const url = new URL(urlPath, c.req.url);
9
+ const headers = new Headers();
10
+ c.req.raw.headers.forEach((value, key) => {
11
+ headers.set(key, value);
12
+ });
13
+ const request = new Request(url, {
14
+ method: c.req.method,
15
+ headers,
16
+ body: ["GET", "HEAD"].includes(c.req.method) ? void 0 : await c.req.text()
17
+ });
18
+ const response = await client.handler(request);
19
+ if (response.status === 404) return next();
20
+ response.headers?.forEach((value, key) => {
21
+ c.header(key, value);
22
+ });
23
+ c.status(response.status);
24
+ if ((response.headers?.get("content-type"))?.includes("text/event-stream") && response.body) return c.body(response.body);
25
+ const body = await response.text();
26
+ return c.body(body);
27
+ };
28
+ }
29
+
30
+ //#endregion
31
+ exports.createLLMOpsMiddleware = createLLMOpsMiddleware;
@@ -0,0 +1,7 @@
1
+ import { t as LLMOpsClient } from "./index-fafxrrPF.cjs";
2
+ import { MiddlewareHandler } from "hono";
3
+
4
+ //#region src/lib/hono/index.d.ts
5
+ declare function createLLMOpsMiddleware(client: LLMOpsClient): MiddlewareHandler;
6
+ //#endregion
7
+ export { createLLMOpsMiddleware };
@@ -0,0 +1,7 @@
1
+ import { t as LLMOpsClient } from "./index-fafxrrPF.cjs";
2
+ import { NextFunction, Request, Response } from "express";
3
+
4
+ //#region src/lib/express/index.d.ts
5
+ declare function createLLMOpsMiddleware(client: LLMOpsClient): (req: Request, res: Response, next: NextFunction) => Promise<void>;
6
+ //#endregion
7
+ export { createLLMOpsMiddleware as t };
@@ -0,0 +1,10 @@
1
+ import { LLMOpsConfig } from "@llmops/core";
2
+
3
+ //#region src/client/index.d.ts
4
+ type LLMOpsClient = {
5
+ handler: (request: Request) => Promise<Response>;
6
+ config: LLMOpsConfig;
7
+ };
8
+ declare const createLLMOps: (config: LLMOpsConfig) => LLMOpsClient;
9
+ //#endregion
10
+ export { createLLMOps as n, LLMOpsClient as t };
package/dist/index.cjs ADDED
@@ -0,0 +1,16 @@
1
+ const require_express = require('./express-B-wbCza5.cjs');
2
+ require("@llmops/core");
3
+ let __llmops_app = require("@llmops/app");
4
+
5
+ //#region src/client/index.ts
6
+ const createLLMOps = (config) => {
7
+ const { app } = (0, __llmops_app.createApp)(config);
8
+ return {
9
+ handler: async (req) => app.fetch(req, void 0, void 0),
10
+ config: Object.freeze(config)
11
+ };
12
+ };
13
+
14
+ //#endregion
15
+ exports.createLLMOpsMiddleware = require_express.createLLMOpsMiddleware;
16
+ exports.llmops = createLLMOps;
@@ -0,0 +1,3 @@
1
+ import { n as createLLMOps } from "./index-fafxrrPF.cjs";
2
+ import { t as createLLMOpsMiddleware } from "./index-UQjBf1t7.cjs";
3
+ export { createLLMOpsMiddleware, createLLMOps as llmops };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llmops/sdk",
3
- "version": "0.1.0-beta.10",
3
+ "version": "0.1.0-beta.11",
4
4
  "description": "An LLMOps toolkit for TypeScript applications",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -17,21 +17,48 @@
17
17
  "files": [
18
18
  "dist"
19
19
  ],
20
- "main": "./dist/index.mjs",
20
+ "main": "./dist/index.cjs",
21
21
  "module": "./dist/index.mjs",
22
22
  "types": "./dist/index.d.mts",
23
23
  "exports": {
24
- ".": "./dist/index.mjs",
25
- "./express": "./dist/express.mjs",
26
- "./hono": "./dist/hono.mjs",
24
+ ".": {
25
+ "import": {
26
+ "types": "./dist/index.d.mts",
27
+ "default": "./dist/index.mjs"
28
+ },
29
+ "require": {
30
+ "types": "./dist/index.d.cts",
31
+ "default": "./dist/index.cjs"
32
+ }
33
+ },
34
+ "./express": {
35
+ "import": {
36
+ "types": "./dist/express.d.mts",
37
+ "default": "./dist/express.mjs"
38
+ },
39
+ "require": {
40
+ "types": "./dist/express.d.cts",
41
+ "default": "./dist/express.cjs"
42
+ }
43
+ },
44
+ "./hono": {
45
+ "import": {
46
+ "types": "./dist/hono.d.mts",
47
+ "default": "./dist/hono.mjs"
48
+ },
49
+ "require": {
50
+ "types": "./dist/hono.d.cts",
51
+ "default": "./dist/hono.cjs"
52
+ }
53
+ },
27
54
  "./*": "./*"
28
55
  },
29
56
  "publishConfig": {
30
57
  "access": "public"
31
58
  },
32
59
  "dependencies": {
33
- "@llmops/core": "^0.1.0-beta.10",
34
- "@llmops/app": "^0.1.0-beta.10"
60
+ "@llmops/app": "^0.1.0-beta.11",
61
+ "@llmops/core": "^0.1.0-beta.11"
35
62
  },
36
63
  "devDependencies": {
37
64
  "@types/express": "^5.0.6",