@zodic/shared 0.0.46 → 0.0.48

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.
@@ -1,12 +1,11 @@
1
1
  import {
2
2
  BackendBindings,
3
3
  BatchInputItem,
4
- BatchProcessingResult,
5
- BatchResponse,
4
+ ChatGPTBatchResponse,
6
5
  ChatGPTFileUploadResponse,
7
6
  ChatMessages,
8
7
  NatalChartInterpretation,
9
- } from '../types';
8
+ } from '../../types';
10
9
  import {
11
10
  AstrologyApiResponse,
12
11
  ChatGPTOptions,
@@ -18,7 +17,7 @@ import {
18
17
  LeonardoUploadImageParams,
19
18
  NatalHouseCuspReport,
20
19
  TimezoneResponse,
21
- } from '../types/scopes/legacy';
20
+ } from '../../types/scopes/legacy';
22
21
  import { makeAstrologyApiCall } from './astrology';
23
22
 
24
23
  export const Api = (env: BackendBindings) => ({
@@ -61,7 +60,7 @@ export const Api = (env: BackendBindings) => ({
61
60
  },
62
61
  batch: async (
63
62
  batchItems: BatchInputItem[]
64
- ): Promise<BatchProcessingResult[]> => {
63
+ ): Promise<ChatGPTBatchResponse> => {
65
64
  console.log('Preparing to send ChatGPT batch request.');
66
65
 
67
66
  const uploadEndpoint = 'https://api.openai.com/v1/files';
@@ -119,16 +118,12 @@ export const Api = (env: BackendBindings) => ({
119
118
  );
120
119
  }
121
120
 
122
- const batchData = (await batchResponse.json()) as BatchResponse;
121
+ const batchData = (await batchResponse.json()) as ChatGPTBatchResponse;
123
122
  console.log(`Batch created successfully. Batch ID: ${batchData.id}`);
124
123
 
125
124
  // Step 3: Poll for batch results (not shown here; depends on the implementation)
126
125
 
127
- return batchItems.map((item) => ({
128
- id: item.id,
129
- status: 'completed', // Placeholder; actual status would depend on polling results
130
- content: undefined, // Placeholder for actual response
131
- }));
126
+ return batchData;
132
127
  } catch (error) {
133
128
  console.error('Error in callChatGPTBatch:', error);
134
129
  throw error;
@@ -1,8 +1,8 @@
1
1
  import { drizzle } from 'drizzle-orm/d1';
2
- import { Api } from '../../api';
3
2
  import * as schema from '../../db/schema';
4
3
  import { BackendBindings } from '../../types';
5
4
  import { buildChatGPTMessages } from '../../utils/buildMessages';
5
+ import { Api } from '../api';
6
6
 
7
7
  export class AppContext {
8
8
  private _drizzle?: ReturnType<typeof drizzle>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -11,7 +11,8 @@
11
11
  "migrate-latest": "wrangler d1 execute DB --file=$(ls -t ./db/migrations/*.sql | head -n 1) --remote --yes",
12
12
  "db:generate": "drizzle-kit generate",
13
13
  "db:up": "drizzle-kit up",
14
- "pub": "npm run db:generate && npm run db:up && npm run migrate-latest && npm publish",
14
+ "pub:db": "npm run db:generate && npm run db:up && npm run migrate-latest && npm version patch && npm publish",
15
+ "pub": "npm version patch && npm publish",
15
16
  "reset-db": "wrangler d1 execute DB --command \"DROP TABLE IF EXISTS migrations;\" && npm run db:up && npm run migrate-latest"
16
17
  },
17
18
  "devDependencies": {
@@ -21,6 +21,7 @@ export type CentralBindings = {
21
21
  KV_USER_GENERATIONS: KVNamespace;
22
22
  KV_COSMIC_MIRROR_ARCHETYPES: KVNamespace;
23
23
  KV_CONCEPTS: KVNamespace;
24
+ KV_CONCEPTS_MANAGEMENT: KVNamespace;
24
25
  KV_LEONARDO_PROMPTS: KVNamespace;
25
26
  KV_TEST: KVNamespace;
26
27
  KV_USER_PRODUCT_STATUS: KVNamespace;
@@ -111,6 +112,7 @@ export type BackendBindings = Env &
111
112
  | 'KV_USER_PRODUCT_STATUS'
112
113
  | 'PIAPI_API_KEY'
113
114
  | 'CONCEPT_GENERATION_QUEUE'
115
+ | 'KV_CONCEPTS_MANAGEMENT'
114
116
  >;
115
117
 
116
118
  export type BackendCtx = Context<
@@ -159,6 +159,44 @@ export type BatchResponse = {
159
159
  error?: any;
160
160
  };
161
161
 
162
+ export type ChatGPTBatchResponse = {
163
+ id: string; // Unique batch ID
164
+ object: string; // Object type (e.g., "batch")
165
+ endpoint: string; // Endpoint associated with the batch (e.g., "/v1/chat/completions")
166
+ errors: null | string; // Errors, if any
167
+ input_file_id: string; // ID of the input file
168
+ completion_window: string; // Time window for completions (e.g., "24h")
169
+ status:
170
+ | "validating"
171
+ | "in_progress"
172
+ | "finalizing"
173
+ | "completed"
174
+ | "failed"
175
+ | "expired"
176
+ | "cancelling"
177
+ | "cancelled"; // Current status of the batch
178
+ output_file_id: string | null; // ID of the output file, if available
179
+ error_file_id: string | null; // ID of the error file, if available
180
+ created_at: number; // Timestamp when the batch was created
181
+ in_progress_at: number | null; // Timestamp when processing started
182
+ expires_at: number | null; // Expiration timestamp
183
+ finalizing_at: number | null; // Timestamp when finalization started
184
+ completed_at: number | null; // Timestamp when the batch completed
185
+ failed_at: number | null; // Timestamp when the batch failed
186
+ expired_at: number | null; // Timestamp when the batch expired
187
+ cancelling_at: number | null; // Timestamp when cancellation started
188
+ cancelled_at: number | null; // Timestamp when the batch was cancelled
189
+ request_counts: {
190
+ total: number; // Total requests in the batch
191
+ completed: number; // Number of completed requests
192
+ failed: number; // Number of failed requests
193
+ };
194
+ metadata: {
195
+ customer_id: string; // Customer ID associated with the batch
196
+ batch_description: string; // Description of the batch
197
+ };
198
+ };
199
+
162
200
  export type BatchProcessingResult = {
163
201
  id: string;
164
202
  status: 'completed' | 'failed';
File without changes