@bodhiapp/ts-client 0.1.2 → 0.1.4
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 +44 -25
- package/dist/index.d.ts +1 -2
- package/dist/index.js +18 -16
- package/dist/index.mjs +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.ts +2 -0
- package/dist/types/types.gen.d.ts +1059 -0
- package/dist/types/types.gen.ts +1218 -0
- package/package.json +17 -10
- package/dist/client.d.ts +0 -23
- package/dist/client.js +0 -47
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bodhiapp/ts-client
|
|
2
2
|
|
|
3
|
-
TypeScript
|
|
3
|
+
TypeScript types for the Bodhi API, providing type-safe access to the API endpoints.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -11,44 +11,50 @@ npm install @bodhiapp/ts-client
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
import { ChatRequest } from "@bodhiapp/ts-client";
|
|
15
|
+
|
|
16
|
+
// Example chat request with type safety
|
|
17
|
+
const request: ChatRequest = {
|
|
18
|
+
model: "llama2",
|
|
19
|
+
messages: [
|
|
20
|
+
{ role: "user", content: "Hello, who are you?" }
|
|
21
|
+
],
|
|
22
|
+
options: {
|
|
23
|
+
temperature: 0.7,
|
|
24
|
+
num_predict: 100
|
|
25
|
+
},
|
|
26
|
+
stream: false
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Make API calls using your preferred HTTP client
|
|
23
30
|
async function chatWithBodhi() {
|
|
24
|
-
const response = await
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
const response = await fetch("http://localhost:3000/v1/chat/completions", {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": "application/json"
|
|
35
|
+
},
|
|
36
|
+
body: JSON.stringify(request)
|
|
30
37
|
});
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// List available models
|
|
36
|
-
async function listAvailableModels() {
|
|
37
|
-
const models = await client.listModels();
|
|
38
|
-
console.log(models.data);
|
|
39
|
+
const data = await response.json();
|
|
40
|
+
console.log(data.choices[0].message.content);
|
|
39
41
|
}
|
|
40
42
|
```
|
|
41
43
|
|
|
42
44
|
## Development
|
|
43
45
|
|
|
44
|
-
This package
|
|
46
|
+
This package provides TypeScript types generated from the Bodhi API OpenAPI specification.
|
|
45
47
|
|
|
46
|
-
To regenerate the
|
|
48
|
+
To regenerate the types:
|
|
47
49
|
|
|
48
50
|
```bash
|
|
49
51
|
npm run generate
|
|
50
52
|
```
|
|
51
53
|
|
|
54
|
+
This will:
|
|
55
|
+
1. Generate the OpenAPI spec from the Rust backend
|
|
56
|
+
2. Generate TypeScript types using @hey-api/openapi-ts
|
|
57
|
+
|
|
52
58
|
To build the package:
|
|
53
59
|
|
|
54
60
|
```bash
|
|
@@ -60,3 +66,16 @@ To run tests:
|
|
|
60
66
|
```bash
|
|
61
67
|
npm test
|
|
62
68
|
```
|
|
69
|
+
|
|
70
|
+
## Types
|
|
71
|
+
|
|
72
|
+
The package exports TypeScript interfaces for all Bodhi API requests and responses. The main types include:
|
|
73
|
+
|
|
74
|
+
- `ChatRequest` - Type for chat completion requests
|
|
75
|
+
- `Message` - Type for chat messages
|
|
76
|
+
- `AppInfo` - Application information and status
|
|
77
|
+
- `Model` - Model information
|
|
78
|
+
- `ApiToken` - API token information
|
|
79
|
+
- And more...
|
|
80
|
+
|
|
81
|
+
All types are fully documented with JSDoc comments for better IDE integration.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './types/api';
|
|
1
|
+
export * from './types';
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
15
13
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/index.ts
|
|
18
|
+
var src_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(src_exports);
|
|
20
|
+
__reExport(src_exports, require("./types"), module.exports);
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types.gen';
|