@hasura/promptql 2.0.0-alpha.1 → 2.0.0-alpha.10
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 +19 -82
- package/biome.json +10 -3
- package/dist/index.d.mts +5155 -0
- package/dist/index.d.ts +5155 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +2 -4
- package/tsconfig.json +25 -4
- package/src/auth/auth.test.ts +0 -24
- package/src/auth/auth.ts +0 -130
- package/src/auth/index.ts +0 -2
- package/src/auth/types.ts +0 -56
- package/src/generated/ChatV2ServerSchema.json +0 -5841
- package/src/generated/ChatV2ServerTypes.ts +0 -2747
- package/src/generated/ThreadEvents.example.json +0 -1645
- package/src/generated/graphql.ts +0 -12121
- package/src/graphql/README.md +0 -70
- package/src/graphql/mutations/sendThreadMessage.gql +0 -16
- package/src/graphql/mutations/startThread.gql +0 -19
- package/src/graphql/queries/getProjectInfo.gql +0 -7
- package/src/graphql/queries/thread.gql +0 -39
- package/src/graphql/subscriptions/subscribeThreadEventsByThreadId.gql +0 -7
- package/src/index.ts +0 -13
- package/src/sdk/apollo.ts +0 -63
- package/src/sdk/client.ts +0 -273
- package/src/sdk/index.ts +0 -4
- package/src/sdk/types.ts +0 -254
- package/src/sdk/utils.ts +0 -684
- package/src/utils.ts +0 -16
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# PromptQL TypeScript SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The PromptQL TypeScript SDK is a general-purpose SDK that interacts with the [PromptQL API](https://promptql.hasura.io) by Hasura. PromptQL enables natural language querying of your data through an AI-powered interface.
|
|
4
|
+
|
|
5
|
+
> [!NOTE]
|
|
6
|
+
> This SDK supports PromptQL v2. Please install [@hasura/promptql@1.0.0](https://www.npmjs.com/package/@hasura/promptql/v/1.0.0) if you wants to integrate PromptQL v1.
|
|
4
7
|
|
|
5
8
|
## Features
|
|
6
9
|
|
|
@@ -21,20 +24,20 @@ A TypeScript SDK for interacting with the [PromptQL API](https://promptql.hasura
|
|
|
21
24
|
## Installation
|
|
22
25
|
|
|
23
26
|
```bash
|
|
24
|
-
npm install @hasura/promptql
|
|
27
|
+
npm install @hasura/promptql@latest
|
|
25
28
|
```
|
|
26
29
|
|
|
27
30
|
Or with your preferred package manager:
|
|
28
31
|
|
|
29
32
|
```bash
|
|
30
33
|
# Yarn
|
|
31
|
-
yarn add @hasura/promptql
|
|
34
|
+
yarn add @hasura/promptql@latest
|
|
32
35
|
|
|
33
36
|
# pnpm
|
|
34
|
-
pnpm add @hasura/promptql
|
|
37
|
+
pnpm add @hasura/promptql@latest
|
|
35
38
|
|
|
36
39
|
# Bun
|
|
37
|
-
bun add @hasura/promptql
|
|
40
|
+
bun add @hasura/promptql@latest
|
|
38
41
|
```
|
|
39
42
|
|
|
40
43
|
## Quick Start
|
|
@@ -63,14 +66,14 @@ const sdk = new PromptQLSdk({
|
|
|
63
66
|
});
|
|
64
67
|
|
|
65
68
|
// Start a new thread
|
|
66
|
-
const thread = await sdk.
|
|
69
|
+
const thread = await sdk.thread.start({
|
|
67
70
|
message: 'What are the top 10 customers by revenue?',
|
|
68
71
|
});
|
|
69
72
|
|
|
70
73
|
console.log('Thread ID:', thread.thread_id);
|
|
71
74
|
|
|
72
75
|
// Stream events from the thread
|
|
73
|
-
sdk.
|
|
76
|
+
sdk.thread.streamEvents(thread.thread_id).subscribe({
|
|
74
77
|
next: (events) => {
|
|
75
78
|
events.forEach(event => {
|
|
76
79
|
console.log('Event:', event);
|
|
@@ -85,13 +88,13 @@ sdk.streamThreadEventsByThreadId(thread.thread_id).subscribe({
|
|
|
85
88
|
|
|
86
89
|
```typescript
|
|
87
90
|
// Send a follow-up message to an existing thread
|
|
88
|
-
const result = await sdk.
|
|
91
|
+
const result = await sdk.thread.sendMessage({
|
|
89
92
|
threadId: 'existing-thread-id',
|
|
90
93
|
message: 'Now show me their average order value',
|
|
91
94
|
});
|
|
92
95
|
|
|
93
96
|
// Stream the response
|
|
94
|
-
sdk.
|
|
97
|
+
sdk.streamEvents(result.thread_id, result.thread_event_id)
|
|
95
98
|
.subscribe({
|
|
96
99
|
next: (events) => console.log('New events:', events),
|
|
97
100
|
});
|
|
@@ -112,14 +115,14 @@ const sdk = new PromptQLSdk({
|
|
|
112
115
|
});
|
|
113
116
|
|
|
114
117
|
// Start a new thread
|
|
115
|
-
const thread = await sdk.
|
|
118
|
+
const thread = await sdk.thread.start({
|
|
116
119
|
message: 'What are the top 10 customers by revenue?',
|
|
117
120
|
});
|
|
118
121
|
|
|
119
122
|
console.log('Thread ID:', thread.thread_id);
|
|
120
123
|
|
|
121
124
|
const events = await lastValueFrom(
|
|
122
|
-
sdk.
|
|
125
|
+
sdk.thread.streamEvents(
|
|
123
126
|
result.thread_id,
|
|
124
127
|
),
|
|
125
128
|
);
|
|
@@ -142,14 +145,14 @@ const sdk = new PromptQLSdk({
|
|
|
142
145
|
});
|
|
143
146
|
|
|
144
147
|
// Start a new thread
|
|
145
|
-
const thread = await sdk.
|
|
148
|
+
const thread = await sdk.thread.start({
|
|
146
149
|
message: 'What are the top 10 customers by revenue?',
|
|
147
150
|
});
|
|
148
151
|
|
|
149
152
|
console.log('Thread ID:', thread.thread_id);
|
|
150
153
|
|
|
151
154
|
// Stream events from the thread
|
|
152
|
-
sdk.
|
|
155
|
+
sdk.streamEvents(thread.thread_id)
|
|
153
156
|
.pipe(
|
|
154
157
|
pairwise(),
|
|
155
158
|
map(([prev, curr]) => diffThreadEvents(prev, curr)),
|
|
@@ -168,7 +171,7 @@ sdk.streamThreadEventsByThreadId(thread.thread_id)
|
|
|
168
171
|
### Listing Threads
|
|
169
172
|
|
|
170
173
|
```typescript
|
|
171
|
-
const threads = await sdk.
|
|
174
|
+
const threads = await sdk.thread.list({
|
|
172
175
|
limit: 20,
|
|
173
176
|
offset: 0,
|
|
174
177
|
order_by: [{ created_at: 'desc' }],
|
|
@@ -185,7 +188,7 @@ threads.forEach(thread => {
|
|
|
185
188
|
### Get a Specific Thread
|
|
186
189
|
|
|
187
190
|
```typescript
|
|
188
|
-
const thread = await sdk.
|
|
191
|
+
const thread = await sdk.thread.get('thread-id');
|
|
189
192
|
console.log('Thread:', thread);
|
|
190
193
|
```
|
|
191
194
|
|
|
@@ -205,7 +208,7 @@ import {
|
|
|
205
208
|
getUserMessageEvent,
|
|
206
209
|
} from '@hasura/promptql';
|
|
207
210
|
|
|
208
|
-
sdk.
|
|
211
|
+
sdk.thread.streamEvents(threadId).subscribe({
|
|
209
212
|
next: (events) => {
|
|
210
213
|
events.forEach(event => {
|
|
211
214
|
// Check for plan generation start
|
|
@@ -288,72 +291,6 @@ interface PromptQLSdkOptions {
|
|
|
288
291
|
}
|
|
289
292
|
```
|
|
290
293
|
|
|
291
|
-
## API Reference
|
|
292
|
-
|
|
293
|
-
### Class: `PromptQLSdk`
|
|
294
|
-
|
|
295
|
-
#### Constructor
|
|
296
|
-
|
|
297
|
-
```typescript
|
|
298
|
-
new PromptQLSdk(options: PromptQLSdkOptions)
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
#### Methods
|
|
302
|
-
|
|
303
|
-
##### `getThreads(variables)`
|
|
304
|
-
|
|
305
|
-
List threads with optional filtering and pagination.
|
|
306
|
-
|
|
307
|
-
```typescript
|
|
308
|
-
getThreads(variables: GetThreadsQueryVariables): Promise<ThreadFragment[]>
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
##### `getThreadById(threadId)`
|
|
312
|
-
|
|
313
|
-
Get a specific thread by ID.
|
|
314
|
-
|
|
315
|
-
```typescript
|
|
316
|
-
getThreadById(threadId: string): Promise<ThreadFragment | null | undefined>
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
##### `startThread(variables)`
|
|
320
|
-
|
|
321
|
-
Start a new thread with a message.
|
|
322
|
-
|
|
323
|
-
```typescript
|
|
324
|
-
startThread(variables: StartThreadArguments): Promise<StartThreadOutput>
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
##### `sendMessageToThread(variables)`
|
|
328
|
-
|
|
329
|
-
Send a message to an existing thread.
|
|
330
|
-
|
|
331
|
-
```typescript
|
|
332
|
-
sendMessageToThread(variables: SendMessageToThreadArguments): Promise<SendMessageToThreadOutput>
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
##### `subscribeThreadEventsByThreadId(threadId, threadEventId?)`
|
|
336
|
-
|
|
337
|
-
Subscribe to events from a thread. Continues indefinitely.
|
|
338
|
-
|
|
339
|
-
```typescript
|
|
340
|
-
subscribeThreadEventsByThreadId(
|
|
341
|
-
threadId: string,
|
|
342
|
-
threadEventId?: string | null
|
|
343
|
-
): Observable<ThreadEvent[]>
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
##### `streamThreadEventsByThreadId(threadId, threadEventId?)`
|
|
347
|
-
|
|
348
|
-
Stream events from a thread. Automatically completes when interaction finishes.
|
|
349
|
-
|
|
350
|
-
```typescript
|
|
351
|
-
streamThreadEventsByThreadId(
|
|
352
|
-
threadId: string,
|
|
353
|
-
threadEventId?: string | null
|
|
354
|
-
): Observable<ThreadEvent[]>
|
|
355
|
-
```
|
|
356
|
-
|
|
357
294
|
## License
|
|
358
295
|
|
|
359
296
|
Apache License 2.0 - see [LICENSE](LICENSE) file for details.
|
package/biome.json
CHANGED
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
"$schema": "https://biomejs.dev/schemas/2.3.13/schema.json",
|
|
3
3
|
"root": false,
|
|
4
4
|
"files": {
|
|
5
|
-
"includes": [
|
|
5
|
+
"includes": [
|
|
6
|
+
"**/*.ts",
|
|
7
|
+
"**/*.gql",
|
|
8
|
+
"!src/generated/*",
|
|
9
|
+
"!dist/**/*"
|
|
10
|
+
]
|
|
6
11
|
},
|
|
7
|
-
"extends": [
|
|
8
|
-
|
|
12
|
+
"extends": [
|
|
13
|
+
"../biome-config/base.json"
|
|
14
|
+
]
|
|
15
|
+
}
|