@bodhiapp/ts-client 0.1.3 → 0.1.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @bodhiapp/ts-client
2
2
 
3
- TypeScript client for the Bodhi API, providing type-safe access to the API endpoints.
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 { BodhiClient } from "@bodhiapp/ts-client";
15
-
16
- // Initialize the client
17
- const client = new BodhiClient({
18
- baseUrl: "https://api.yourdomain.com",
19
- apiKey: "your-api-key",
20
- });
21
-
22
- // Create a chat completion
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 client.createChatCompletion({
25
- model: "gpt-3.5-turbo",
26
- messages: [
27
- { role: "system", content: "You are a helpful assistant." },
28
- { role: "user", content: "Hello, who are you?" },
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
- console.log(response.choices[0].message.content);
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 is generated from the Bodhi API OpenAPI specification.
46
+ This package provides TypeScript types generated from the Bodhi API OpenAPI specification.
45
47
 
46
- To regenerate the client:
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 +1 @@
1
- export * from './types/api';
1
+ export * from './types';
package/dist/index.js CHANGED
@@ -17,4 +17,4 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
17
17
  // src/index.ts
18
18
  var src_exports = {};
19
19
  module.exports = __toCommonJS(src_exports);
20
- __reExport(src_exports, require("./types/api"), module.exports);
20
+ __reExport(src_exports, require("./types"), module.exports);
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  // src/index.ts
2
- export * from "./types/api";
2
+ export * from "./types";
@@ -0,0 +1 @@
1
+ export * from './types.gen';
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export * from './types.gen';