@qbraid-core/chat 0.1.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 +21 -0
- package/dist/src/client.d.ts +7 -0
- package/dist/src/client.js +21 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types.d.ts +20 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @qbraid-core/chat
|
|
2
|
+
|
|
3
|
+
Client for the qBraid AI Chat service.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @qbraid-core/chat
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage Example
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { ChatClient } from '@qbraid-core/chat';
|
|
15
|
+
|
|
16
|
+
const client = new ChatClient();
|
|
17
|
+
|
|
18
|
+
const response = await client.createMessage('What is the Schrödinger equation?');
|
|
19
|
+
|
|
20
|
+
console.log(response.content);
|
|
21
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Config, QbraidClient } from '@qbraid-core/base';
|
|
2
|
+
import { ChatModel, ChatResponse } from './types';
|
|
3
|
+
export declare class ChatClient extends QbraidClient {
|
|
4
|
+
constructor(config?: Config);
|
|
5
|
+
createMessage(prompt: string, model?: string): Promise<ChatResponse>;
|
|
6
|
+
getModels(): Promise<ChatModel[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChatClient = void 0;
|
|
4
|
+
const base_1 = require("@qbraid-core/base");
|
|
5
|
+
class ChatClient extends base_1.QbraidClient {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
super(config);
|
|
8
|
+
}
|
|
9
|
+
async createMessage(prompt, model = 'gpt-4o-mini') {
|
|
10
|
+
const response = await this.session.request('POST', '/chat', {
|
|
11
|
+
data: { prompt, model },
|
|
12
|
+
});
|
|
13
|
+
return response.data;
|
|
14
|
+
}
|
|
15
|
+
async getModels() {
|
|
16
|
+
const response = await this.session.request('GET', '/chat/models');
|
|
17
|
+
return response.data;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.ChatClient = ChatClient;
|
|
21
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAAA,4CAAyD;AAGzD,MAAa,UAAW,SAAQ,mBAAY;IAC1C,YAAY,MAAe;QACzB,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,MAAc,EAAE,KAAK,GAAG,aAAa;QACvD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAe,MAAM,EAAE,OAAO,EAAE;YACzE,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;SACxB,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAc,KAAK,EAAE,cAAc,CAAC,CAAC;QAChF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AAhBD,gCAgBC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChatClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module chat
|
|
6
|
+
*/
|
|
7
|
+
var client_1 = require("./client");
|
|
8
|
+
Object.defineProperty(exports, "ChatClient", { enumerable: true, get: function () { return client_1.ChatClient; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mCAAsC;AAA7B,oGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ChatModelPricing {
|
|
2
|
+
units: string;
|
|
3
|
+
input: number;
|
|
4
|
+
output: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ChatModel {
|
|
7
|
+
model: string;
|
|
8
|
+
description: string;
|
|
9
|
+
pricing: ChatModelPricing;
|
|
10
|
+
}
|
|
11
|
+
export interface ChatResponse {
|
|
12
|
+
content: string;
|
|
13
|
+
usage?: {
|
|
14
|
+
prompt_tokens: number;
|
|
15
|
+
completion_tokens: number;
|
|
16
|
+
total_tokens: number;
|
|
17
|
+
prompt_tokens_details?: Record<string, number>;
|
|
18
|
+
completion_tokens_details?: Record<string, number>;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qbraid-core/chat",
|
|
3
|
+
"description": "Client for the qBraid AI Chat service.",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"types": "dist/src/index.d.ts",
|
|
7
|
+
"author": "qBraid Development Team",
|
|
8
|
+
"license": "Proprietary",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/src"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"qbraid",
|
|
14
|
+
"qbraid-core",
|
|
15
|
+
"qbraid-core-js",
|
|
16
|
+
"qbraid chat",
|
|
17
|
+
"qbraid ai",
|
|
18
|
+
"qbraid ai chat",
|
|
19
|
+
"ai",
|
|
20
|
+
"ai chat",
|
|
21
|
+
"qbraid cloud",
|
|
22
|
+
"qbraid api",
|
|
23
|
+
"qbraid apis",
|
|
24
|
+
"cloud",
|
|
25
|
+
"quantum",
|
|
26
|
+
"quantum computing"
|
|
27
|
+
],
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"directory": "packages/chat",
|
|
31
|
+
"url": "git+https://github.com/qBraid/qbraid-core-js.git"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://qbraid.github.io/qbraid-core-js/modules/chat.html",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@qbraid-core/base": "0.1.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"clean": "rimraf dist && rimraf tsconfig.tsbuildinfo",
|
|
39
|
+
"lint": "eslint src",
|
|
40
|
+
"lint:fix": "eslint src --fix",
|
|
41
|
+
"format": "prettier --write \"src/**/*.{ts,json}\"",
|
|
42
|
+
"format:check": "prettier --check \"src/**/*.{ts,json}\"",
|
|
43
|
+
"docs": "typedoc"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20"
|
|
47
|
+
}
|
|
48
|
+
}
|