@zodic/shared 0.0.69 → 0.0.71

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/app/api/index.ts CHANGED
@@ -1,9 +1,13 @@
1
+ import OpenAI from 'openai';
1
2
  import {
2
3
  BackendBindings,
3
4
  BatchInputItem,
4
5
  ChatGPTBatchResponse,
5
6
  ChatGPTFileUploadResponse,
6
7
  ChatMessages,
8
+ DeepSeekBatchInputItem,
9
+ DeepSeekBatchResponse,
10
+ DeepSeekOptions,
7
11
  NatalChartInterpretation,
8
12
  } from '../../types';
9
13
  import {
@@ -20,7 +24,70 @@ import {
20
24
  } from '../../types/scopes/legacy';
21
25
  import { makeAstrologyApiCall } from './astrology';
22
26
 
27
+ const deepseek = (env: BackendBindings) =>
28
+ new OpenAI({
29
+ apiKey: env.DEEPSEEK_API_KEY, // Replace with your DeepSeek API key
30
+ baseURL: 'https://api.deepseek.com/v1', // DeepSeek's API endpoint
31
+ });
32
+
23
33
  export const Api = (env: BackendBindings) => ({
34
+ callDeepSeek: {
35
+ single: async (
36
+ messages: ChatMessages,
37
+ { model = 'deepseek-v3', options = {} }: DeepSeekOptions
38
+ ): Promise<string> => {
39
+ try {
40
+ const response = await deepseek(env).chat.completions.create({
41
+ model,
42
+ messages,
43
+ ...options,
44
+ });
45
+
46
+ if (response.choices[0].message.content) {
47
+ return response.choices[0].message.content.trim();
48
+ } else {
49
+ throw new Error('Content is null');
50
+ }
51
+ } catch (err: any) {
52
+ console.error('Error calling DeepSeek API:', err.message);
53
+ throw err;
54
+ }
55
+ },
56
+
57
+ batch: async (
58
+ batchItems: DeepSeekBatchInputItem[]
59
+ ): Promise<DeepSeekBatchResponse> => {
60
+ console.log('Preparing to send DeepSeek batch request.');
61
+
62
+ try {
63
+ const responses: DeepSeekBatchResponse = [];
64
+
65
+ for (const item of batchItems) {
66
+ const { messages, options } = item;
67
+ const response = await deepseek(env).chat.completions.create({
68
+ model: options?.model || 'deepseek-v3',
69
+ messages,
70
+ ...options,
71
+ });
72
+
73
+ if (response.choices[0].message.content) {
74
+ responses.push({
75
+ input: item,
76
+ output: response.choices[0].message.content.trim(),
77
+ });
78
+ } else {
79
+ console.error('Content is null');
80
+ }
81
+ }
82
+
83
+ console.log('Batch processing completed successfully.');
84
+ return responses;
85
+ } catch (error) {
86
+ console.error('Error in callDeepSeekBatch:', error);
87
+ throw error;
88
+ }
89
+ },
90
+ },
24
91
  callChatGPT: {
25
92
  single: async (
26
93
  messages: ChatMessages,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.69",
3
+ "version": "0.0.71",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -31,6 +31,7 @@
31
31
  "hono": "^4.6.13",
32
32
  "inversify": "^6.2.1",
33
33
  "jose": "^5.9.6",
34
+ "openai": "^4.81.0",
34
35
  "reflect-metadata": "^0.2.2"
35
36
  }
36
37
  }
@@ -54,6 +54,7 @@ export type CentralBindings = {
54
54
  ASTROLOGY_PDF_USER_ID: string;
55
55
  ASTROLOGY_PDF_API_KEY: string;
56
56
  PIAPI_API_KEY: string;
57
+ DEEPSEEK_API_KEY: string;
57
58
 
58
59
  API_BASE_URL: string;
59
60
  PUBLIC_GOOGLE_CLIENT_ID: string;
@@ -113,6 +114,7 @@ export type BackendBindings = Env &
113
114
  | 'PIAPI_API_KEY'
114
115
  | 'CONCEPT_GENERATION_QUEUE'
115
116
  | 'KV_CONCEPTS_MANAGEMENT'
117
+ | 'DEEPSEEK_API_KEY'
116
118
  >;
117
119
 
118
120
  export type BackendCtx = Context<
@@ -17,7 +17,6 @@ export const ProductType = {
17
17
  REPORT: 'report',
18
18
  };
19
19
 
20
-
21
20
  export const VALID_GENDERS_ARRAY = ['male', 'female', 'non-binary'] as const;
22
21
 
23
22
  export type Gender = (typeof VALID_GENDERS_ARRAY)[number];
@@ -241,3 +240,13 @@ export const ConceptPhases: Record<string, ConceptPhase> = {
241
240
  CONTENT: 'content',
242
241
  IMAGES: 'images',
243
242
  };
243
+
244
+ export type DeepSeekOptions = { model?: string; options?: Record<string, any> };
245
+ export type DeepSeekBatchInputItem = {
246
+ messages: ChatMessages;
247
+ options?: DeepSeekOptions;
248
+ };
249
+ export type DeepSeekBatchResponse = Array<{
250
+ input: DeepSeekBatchInputItem;
251
+ output: string;
252
+ }>;
@@ -104,10 +104,11 @@ export type KVArchetype = {
104
104
  description: string;
105
105
  content: string;
106
106
  leonardoPrompt: string;
107
- virtues: string;
107
+ virtues: string[];
108
108
  images: LeonardoImage[];
109
109
  status: 'idle' | 'generating' | 'completed';
110
110
  };
111
+
111
112
  export type KVConcept = {
112
113
  name: string;
113
114
  description: string;