@vitkuz/vitkuz-chat-gpt-apapter 1.2.0 → 1.2.1

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/dist/index.d.mts CHANGED
@@ -85,7 +85,9 @@ declare const createAdapter: (config: ChatGptConfig, logger?: Logger) => ChatGpt
85
85
 
86
86
  declare const CHAT_GPT_MODELS: {
87
87
  readonly GPT_4o: "gpt-4o";
88
+ readonly GPT_4o_2024_08_06: "gpt-4o-2024-08-06";
88
89
  readonly GPT_4o_MINI: "gpt-4o-mini";
90
+ readonly GPT_4o_MINI_2024_07_18: "gpt-4o-mini-2024-07-18";
89
91
  readonly GPT_4_TURBO: "gpt-4-turbo";
90
92
  readonly GPT_4: "gpt-4";
91
93
  readonly GPT_3_5_TURBO: "gpt-3.5-turbo";
package/dist/index.d.ts CHANGED
@@ -85,7 +85,9 @@ declare const createAdapter: (config: ChatGptConfig, logger?: Logger) => ChatGpt
85
85
 
86
86
  declare const CHAT_GPT_MODELS: {
87
87
  readonly GPT_4o: "gpt-4o";
88
+ readonly GPT_4o_2024_08_06: "gpt-4o-2024-08-06";
88
89
  readonly GPT_4o_MINI: "gpt-4o-mini";
90
+ readonly GPT_4o_MINI_2024_07_18: "gpt-4o-mini-2024-07-18";
89
91
  readonly GPT_4_TURBO: "gpt-4-turbo";
90
92
  readonly GPT_4: "gpt-4";
91
93
  readonly GPT_3_5_TURBO: "gpt-3.5-turbo";
package/dist/index.js CHANGED
@@ -64,7 +64,9 @@ var createAdapter = (config, logger) => {
64
64
  // src/models.ts
65
65
  var CHAT_GPT_MODELS = {
66
66
  GPT_4o: "gpt-4o",
67
+ GPT_4o_2024_08_06: "gpt-4o-2024-08-06",
67
68
  GPT_4o_MINI: "gpt-4o-mini",
69
+ GPT_4o_MINI_2024_07_18: "gpt-4o-mini-2024-07-18",
68
70
  GPT_4_TURBO: "gpt-4-turbo",
69
71
  GPT_4: "gpt-4",
70
72
  GPT_3_5_TURBO: "gpt-3.5-turbo"
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/operations/create-chat-completion.ts","../src/adapter.ts","../src/models.ts"],"names":["OpenAI","response","zodTextFormat"],"mappings":";;;;;;;;;;AAGO,IAAM,mBAAA,GAAsB,CAAC,MAAA,KAAkC;AAClE,EAAA,OAAO,IAAIA,uBAAA,CAAO;AAAA,IACd,QAAQ,MAAA,CAAO,MAAA;AAAA,IACf,cAAc,MAAA,CAAO,YAAA;AAAA,IACrB,SAAS,MAAA,CAAO;AAAA,GACnB,CAAA;AACL;ACNO,IAAM,oBAAA,GACT,CAAC,GAAA,KACD,OAAO,KAAA,KAA0E;AAC7E,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAS,GAAI,GAAA;AAErC,EAAA,MAAM,WAAA,GAAc;AAAA,IAChB,GAAG,QAAA;AAAA,IACH,GAAG;AAAA,GACP;AAEA,EAAA,IAAI,CAAC,YAAY,KAAA,EAAO;AACpB,IAAA,MAAM,IAAI,MAAM,kDAAkD,CAAA;AAAA,EACtE;AAEA,EAAA,MAAM,EAAE,MAAA,EAAQ,UAAA,EAAY,QAAA,EAAU,GAAG,MAAK,GAAI,WAAA;AAElD,EAAA,MAAA,EAAQ,KAAA,CAAM,qCAAA,EAAuC,EAAE,IAAA,EAAM,aAAa,CAAA;AAE1E,EAAA,IAAI;AACA,IAAA,IAAI,MAAA,EAAQ;AACR,MAAA,MAAMC,SAAAA,GAAW,MAAO,MAAA,CAAO,SAAA,CAAkB,KAAA,CAAM;AAAA,QACnD,GAAG,IAAA;AAAA,QACH,KAAA,EAAO,QAAA;AAAA,QACP,IAAA,EAAM;AAAA,UACF,MAAA,EAAQC,iBAAA,CAAc,MAAA,EAAQ,UAAA,IAAc,QAAQ;AAAA;AACxD,OACH,CAAA;AAED,MAAA,MAAA,EAAQ,KAAA,CAAM,uCAAA,EAAyC,EAAE,IAAA,EAAMD,WAAU,CAAA;AAEzE,MAAA,OAAO;AAAA,QACH,GAAGA,SAAAA;AAAA,QACH,QAAQA,SAAAA,CAAS;AAAA,OACrB;AAAA,IACJ;AAIA,IAAA,MAAM,QAAA,GAAW,MAAM,MAAA,CAAO,IAAA,CAAK,YAAY,MAAA,CAAO;AAAA,MAClD,GAAG;AAAA,KACC,CAAA;AAER,IAAA,MAAA,EAAQ,KAAA,CAAM,uCAAA,EAAyC,EAAE,IAAA,EAAM,UAAU,CAAA;AAEzE,IAAA,OAAO,QAAA;AAAA,EACX,SAAS,KAAA,EAAO;AACZ,IAAA,MAAA,EAAQ,KAAA,CAAM,qCAAA,EAAuC,EAAE,KAAA,EAAO,CAAA;AAC9D,IAAA,MAAM,KAAA;AAAA,EACV;AACJ;;;AC3CG,IAAM,aAAA,GAAgB,CAAC,MAAA,EAAuB,MAAA,KAAoC;AACrF,EAAA,MAAM,MAAA,GAAS,oBAAoB,MAAM,CAAA;AACzC,EAAA,MAAM,UAA0B,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAU,OAAO,QAAA,EAAS;AAE5E,EAAA,OAAO;AAAA,IACH,oBAAA,EAAsB,qBAAqB,OAAO;AAAA,GACtD;AACJ;;;AChBO,IAAM,eAAA,GAAkB;AAAA,EAC3B,MAAA,EAAQ,QAAA;AAAA,EACR,WAAA,EAAa,aAAA;AAAA,EACb,WAAA,EAAa,aAAA;AAAA,EACb,KAAA,EAAO,OAAA;AAAA,EACP,aAAA,EAAe;AACnB","file":"index.js","sourcesContent":["import OpenAI from 'openai';\nimport { ChatGptConfig } from './types';\n\nexport const createChatGptClient = (config: ChatGptConfig): OpenAI => {\n return new OpenAI({\n apiKey: config.apiKey,\n organization: config.organization,\n project: config.project,\n });\n};\n","import { zodTextFormat } from 'openai/helpers/zod';\nimport { ChatGptContext, CreateChatCompletionInput, CreateChatCompletionOutput } from '../types';\n\nexport const createChatCompletion =\n (ctx: ChatGptContext) =>\n async (input: CreateChatCompletionInput): Promise<CreateChatCompletionOutput> => {\n const { client, logger, defaults } = ctx;\n\n const mergedInput = {\n ...defaults,\n ...input,\n };\n\n if (!mergedInput.model) {\n throw new Error('chat-gpt:createChatCompletion: model is required');\n }\n\n const { schema, schemaName, messages, ...rest } = mergedInput;\n\n logger?.debug('chat-gpt:createChatCompletion:start', { data: mergedInput });\n\n try {\n if (schema) {\n const response = await (client.responses as any).parse({\n ...rest,\n input: messages,\n text: {\n format: zodTextFormat(schema, schemaName || 'output'),\n },\n });\n\n logger?.debug('chat-gpt:createChatCompletion:success', { data: response });\n\n return {\n ...response,\n parsed: response.output_parsed,\n } as CreateChatCompletionOutput;\n }\n\n // Fallback to regular chat completion for non-zod calls\n // or we can use client.responses.create if we want to be consistent\n const response = await client.chat.completions.create({\n ...mergedInput,\n } as any);\n\n logger?.debug('chat-gpt:createChatCompletion:success', { data: response });\n\n return response as CreateChatCompletionOutput;\n } catch (error) {\n logger?.debug('chat-gpt:createChatCompletion:error', { error });\n throw error;\n }\n };\n","import OpenAI from 'openai';\nimport { ChatGptConfig, ChatGptContext, Logger } from './types';\nimport { createChatGptClient } from './client';\nimport { createChatCompletion } from './operations/create-chat-completion';\n\nexport interface ChatGptAdapter {\n createChatCompletion: ReturnType<typeof createChatCompletion>;\n}\n\nexport const createAdapter = (config: ChatGptConfig, logger?: Logger): ChatGptAdapter => {\n const client = createChatGptClient(config);\n const context: ChatGptContext = { client, logger, defaults: config.defaults };\n\n return {\n createChatCompletion: createChatCompletion(context),\n };\n};\n","export const CHAT_GPT_MODELS = {\n GPT_4o: 'gpt-4o',\n GPT_4o_MINI: 'gpt-4o-mini',\n GPT_4_TURBO: 'gpt-4-turbo',\n GPT_4: 'gpt-4',\n GPT_3_5_TURBO: 'gpt-3.5-turbo',\n} as const;\n\nexport type ChatGptModel = (typeof CHAT_GPT_MODELS)[keyof typeof CHAT_GPT_MODELS];\n"]}
1
+ {"version":3,"sources":["../src/client.ts","../src/operations/create-chat-completion.ts","../src/adapter.ts","../src/models.ts"],"names":["OpenAI","response","zodTextFormat"],"mappings":";;;;;;;;;;AAGO,IAAM,mBAAA,GAAsB,CAAC,MAAA,KAAkC;AAClE,EAAA,OAAO,IAAIA,uBAAA,CAAO;AAAA,IACd,QAAQ,MAAA,CAAO,MAAA;AAAA,IACf,cAAc,MAAA,CAAO,YAAA;AAAA,IACrB,SAAS,MAAA,CAAO;AAAA,GACnB,CAAA;AACL;ACNO,IAAM,oBAAA,GACT,CAAC,GAAA,KACD,OAAO,KAAA,KAA0E;AAC7E,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAS,GAAI,GAAA;AAErC,EAAA,MAAM,WAAA,GAAc;AAAA,IAChB,GAAG,QAAA;AAAA,IACH,GAAG;AAAA,GACP;AAEA,EAAA,IAAI,CAAC,YAAY,KAAA,EAAO;AACpB,IAAA,MAAM,IAAI,MAAM,kDAAkD,CAAA;AAAA,EACtE;AAEA,EAAA,MAAM,EAAE,MAAA,EAAQ,UAAA,EAAY,QAAA,EAAU,GAAG,MAAK,GAAI,WAAA;AAElD,EAAA,MAAA,EAAQ,KAAA,CAAM,qCAAA,EAAuC,EAAE,IAAA,EAAM,aAAa,CAAA;AAE1E,EAAA,IAAI;AACA,IAAA,IAAI,MAAA,EAAQ;AACR,MAAA,MAAMC,SAAAA,GAAW,MAAO,MAAA,CAAO,SAAA,CAAkB,KAAA,CAAM;AAAA,QACnD,GAAG,IAAA;AAAA,QACH,KAAA,EAAO,QAAA;AAAA,QACP,IAAA,EAAM;AAAA,UACF,MAAA,EAAQC,iBAAA,CAAc,MAAA,EAAQ,UAAA,IAAc,QAAQ;AAAA;AACxD,OACH,CAAA;AAED,MAAA,MAAA,EAAQ,KAAA,CAAM,uCAAA,EAAyC,EAAE,IAAA,EAAMD,WAAU,CAAA;AAEzE,MAAA,OAAO;AAAA,QACH,GAAGA,SAAAA;AAAA,QACH,QAAQA,SAAAA,CAAS;AAAA,OACrB;AAAA,IACJ;AAIA,IAAA,MAAM,QAAA,GAAW,MAAM,MAAA,CAAO,IAAA,CAAK,YAAY,MAAA,CAAO;AAAA,MAClD,GAAG;AAAA,KACC,CAAA;AAER,IAAA,MAAA,EAAQ,KAAA,CAAM,uCAAA,EAAyC,EAAE,IAAA,EAAM,UAAU,CAAA;AAEzE,IAAA,OAAO,QAAA;AAAA,EACX,SAAS,KAAA,EAAO;AACZ,IAAA,MAAA,EAAQ,KAAA,CAAM,qCAAA,EAAuC,EAAE,KAAA,EAAO,CAAA;AAC9D,IAAA,MAAM,KAAA;AAAA,EACV;AACJ;;;AC3CG,IAAM,aAAA,GAAgB,CAAC,MAAA,EAAuB,MAAA,KAAoC;AACrF,EAAA,MAAM,MAAA,GAAS,oBAAoB,MAAM,CAAA;AACzC,EAAA,MAAM,UAA0B,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAU,OAAO,QAAA,EAAS;AAE5E,EAAA,OAAO;AAAA,IACH,oBAAA,EAAsB,qBAAqB,OAAO;AAAA,GACtD;AACJ;;;AChBO,IAAM,eAAA,GAAkB;AAAA,EAC3B,MAAA,EAAQ,QAAA;AAAA,EACR,iBAAA,EAAmB,mBAAA;AAAA,EACnB,WAAA,EAAa,aAAA;AAAA,EACb,sBAAA,EAAwB,wBAAA;AAAA,EACxB,WAAA,EAAa,aAAA;AAAA,EACb,KAAA,EAAO,OAAA;AAAA,EACP,aAAA,EAAe;AACnB","file":"index.js","sourcesContent":["import OpenAI from 'openai';\nimport { ChatGptConfig } from './types';\n\nexport const createChatGptClient = (config: ChatGptConfig): OpenAI => {\n return new OpenAI({\n apiKey: config.apiKey,\n organization: config.organization,\n project: config.project,\n });\n};\n","import { zodTextFormat } from 'openai/helpers/zod';\nimport { ChatGptContext, CreateChatCompletionInput, CreateChatCompletionOutput } from '../types';\n\nexport const createChatCompletion =\n (ctx: ChatGptContext) =>\n async (input: CreateChatCompletionInput): Promise<CreateChatCompletionOutput> => {\n const { client, logger, defaults } = ctx;\n\n const mergedInput = {\n ...defaults,\n ...input,\n };\n\n if (!mergedInput.model) {\n throw new Error('chat-gpt:createChatCompletion: model is required');\n }\n\n const { schema, schemaName, messages, ...rest } = mergedInput;\n\n logger?.debug('chat-gpt:createChatCompletion:start', { data: mergedInput });\n\n try {\n if (schema) {\n const response = await (client.responses as any).parse({\n ...rest,\n input: messages,\n text: {\n format: zodTextFormat(schema, schemaName || 'output'),\n },\n });\n\n logger?.debug('chat-gpt:createChatCompletion:success', { data: response });\n\n return {\n ...response,\n parsed: response.output_parsed,\n } as CreateChatCompletionOutput;\n }\n\n // Fallback to regular chat completion for non-zod calls\n // or we can use client.responses.create if we want to be consistent\n const response = await client.chat.completions.create({\n ...mergedInput,\n } as any);\n\n logger?.debug('chat-gpt:createChatCompletion:success', { data: response });\n\n return response as CreateChatCompletionOutput;\n } catch (error) {\n logger?.debug('chat-gpt:createChatCompletion:error', { error });\n throw error;\n }\n };\n","import OpenAI from 'openai';\nimport { ChatGptConfig, ChatGptContext, Logger } from './types';\nimport { createChatGptClient } from './client';\nimport { createChatCompletion } from './operations/create-chat-completion';\n\nexport interface ChatGptAdapter {\n createChatCompletion: ReturnType<typeof createChatCompletion>;\n}\n\nexport const createAdapter = (config: ChatGptConfig, logger?: Logger): ChatGptAdapter => {\n const client = createChatGptClient(config);\n const context: ChatGptContext = { client, logger, defaults: config.defaults };\n\n return {\n createChatCompletion: createChatCompletion(context),\n };\n};\n","export const CHAT_GPT_MODELS = {\n GPT_4o: 'gpt-4o',\n GPT_4o_2024_08_06: 'gpt-4o-2024-08-06',\n GPT_4o_MINI: 'gpt-4o-mini',\n GPT_4o_MINI_2024_07_18: 'gpt-4o-mini-2024-07-18',\n GPT_4_TURBO: 'gpt-4-turbo',\n GPT_4: 'gpt-4',\n GPT_3_5_TURBO: 'gpt-3.5-turbo',\n} as const;\n\nexport type ChatGptModel = (typeof CHAT_GPT_MODELS)[keyof typeof CHAT_GPT_MODELS];\n"]}
package/dist/index.mjs CHANGED
@@ -58,7 +58,9 @@ var createAdapter = (config, logger) => {
58
58
  // src/models.ts
59
59
  var CHAT_GPT_MODELS = {
60
60
  GPT_4o: "gpt-4o",
61
+ GPT_4o_2024_08_06: "gpt-4o-2024-08-06",
61
62
  GPT_4o_MINI: "gpt-4o-mini",
63
+ GPT_4o_MINI_2024_07_18: "gpt-4o-mini-2024-07-18",
62
64
  GPT_4_TURBO: "gpt-4-turbo",
63
65
  GPT_4: "gpt-4",
64
66
  GPT_3_5_TURBO: "gpt-3.5-turbo"
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/operations/create-chat-completion.ts","../src/adapter.ts","../src/models.ts"],"names":["response"],"mappings":";;;;AAGO,IAAM,mBAAA,GAAsB,CAAC,MAAA,KAAkC;AAClE,EAAA,OAAO,IAAI,MAAA,CAAO;AAAA,IACd,QAAQ,MAAA,CAAO,MAAA;AAAA,IACf,cAAc,MAAA,CAAO,YAAA;AAAA,IACrB,SAAS,MAAA,CAAO;AAAA,GACnB,CAAA;AACL;ACNO,IAAM,oBAAA,GACT,CAAC,GAAA,KACD,OAAO,KAAA,KAA0E;AAC7E,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAS,GAAI,GAAA;AAErC,EAAA,MAAM,WAAA,GAAc;AAAA,IAChB,GAAG,QAAA;AAAA,IACH,GAAG;AAAA,GACP;AAEA,EAAA,IAAI,CAAC,YAAY,KAAA,EAAO;AACpB,IAAA,MAAM,IAAI,MAAM,kDAAkD,CAAA;AAAA,EACtE;AAEA,EAAA,MAAM,EAAE,MAAA,EAAQ,UAAA,EAAY,QAAA,EAAU,GAAG,MAAK,GAAI,WAAA;AAElD,EAAA,MAAA,EAAQ,KAAA,CAAM,qCAAA,EAAuC,EAAE,IAAA,EAAM,aAAa,CAAA;AAE1E,EAAA,IAAI;AACA,IAAA,IAAI,MAAA,EAAQ;AACR,MAAA,MAAMA,SAAAA,GAAW,MAAO,MAAA,CAAO,SAAA,CAAkB,KAAA,CAAM;AAAA,QACnD,GAAG,IAAA;AAAA,QACH,KAAA,EAAO,QAAA;AAAA,QACP,IAAA,EAAM;AAAA,UACF,MAAA,EAAQ,aAAA,CAAc,MAAA,EAAQ,UAAA,IAAc,QAAQ;AAAA;AACxD,OACH,CAAA;AAED,MAAA,MAAA,EAAQ,KAAA,CAAM,uCAAA,EAAyC,EAAE,IAAA,EAAMA,WAAU,CAAA;AAEzE,MAAA,OAAO;AAAA,QACH,GAAGA,SAAAA;AAAA,QACH,QAAQA,SAAAA,CAAS;AAAA,OACrB;AAAA,IACJ;AAIA,IAAA,MAAM,QAAA,GAAW,MAAM,MAAA,CAAO,IAAA,CAAK,YAAY,MAAA,CAAO;AAAA,MAClD,GAAG;AAAA,KACC,CAAA;AAER,IAAA,MAAA,EAAQ,KAAA,CAAM,uCAAA,EAAyC,EAAE,IAAA,EAAM,UAAU,CAAA;AAEzE,IAAA,OAAO,QAAA;AAAA,EACX,SAAS,KAAA,EAAO;AACZ,IAAA,MAAA,EAAQ,KAAA,CAAM,qCAAA,EAAuC,EAAE,KAAA,EAAO,CAAA;AAC9D,IAAA,MAAM,KAAA;AAAA,EACV;AACJ;;;AC3CG,IAAM,aAAA,GAAgB,CAAC,MAAA,EAAuB,MAAA,KAAoC;AACrF,EAAA,MAAM,MAAA,GAAS,oBAAoB,MAAM,CAAA;AACzC,EAAA,MAAM,UAA0B,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAU,OAAO,QAAA,EAAS;AAE5E,EAAA,OAAO;AAAA,IACH,oBAAA,EAAsB,qBAAqB,OAAO;AAAA,GACtD;AACJ;;;AChBO,IAAM,eAAA,GAAkB;AAAA,EAC3B,MAAA,EAAQ,QAAA;AAAA,EACR,WAAA,EAAa,aAAA;AAAA,EACb,WAAA,EAAa,aAAA;AAAA,EACb,KAAA,EAAO,OAAA;AAAA,EACP,aAAA,EAAe;AACnB","file":"index.mjs","sourcesContent":["import OpenAI from 'openai';\nimport { ChatGptConfig } from './types';\n\nexport const createChatGptClient = (config: ChatGptConfig): OpenAI => {\n return new OpenAI({\n apiKey: config.apiKey,\n organization: config.organization,\n project: config.project,\n });\n};\n","import { zodTextFormat } from 'openai/helpers/zod';\nimport { ChatGptContext, CreateChatCompletionInput, CreateChatCompletionOutput } from '../types';\n\nexport const createChatCompletion =\n (ctx: ChatGptContext) =>\n async (input: CreateChatCompletionInput): Promise<CreateChatCompletionOutput> => {\n const { client, logger, defaults } = ctx;\n\n const mergedInput = {\n ...defaults,\n ...input,\n };\n\n if (!mergedInput.model) {\n throw new Error('chat-gpt:createChatCompletion: model is required');\n }\n\n const { schema, schemaName, messages, ...rest } = mergedInput;\n\n logger?.debug('chat-gpt:createChatCompletion:start', { data: mergedInput });\n\n try {\n if (schema) {\n const response = await (client.responses as any).parse({\n ...rest,\n input: messages,\n text: {\n format: zodTextFormat(schema, schemaName || 'output'),\n },\n });\n\n logger?.debug('chat-gpt:createChatCompletion:success', { data: response });\n\n return {\n ...response,\n parsed: response.output_parsed,\n } as CreateChatCompletionOutput;\n }\n\n // Fallback to regular chat completion for non-zod calls\n // or we can use client.responses.create if we want to be consistent\n const response = await client.chat.completions.create({\n ...mergedInput,\n } as any);\n\n logger?.debug('chat-gpt:createChatCompletion:success', { data: response });\n\n return response as CreateChatCompletionOutput;\n } catch (error) {\n logger?.debug('chat-gpt:createChatCompletion:error', { error });\n throw error;\n }\n };\n","import OpenAI from 'openai';\nimport { ChatGptConfig, ChatGptContext, Logger } from './types';\nimport { createChatGptClient } from './client';\nimport { createChatCompletion } from './operations/create-chat-completion';\n\nexport interface ChatGptAdapter {\n createChatCompletion: ReturnType<typeof createChatCompletion>;\n}\n\nexport const createAdapter = (config: ChatGptConfig, logger?: Logger): ChatGptAdapter => {\n const client = createChatGptClient(config);\n const context: ChatGptContext = { client, logger, defaults: config.defaults };\n\n return {\n createChatCompletion: createChatCompletion(context),\n };\n};\n","export const CHAT_GPT_MODELS = {\n GPT_4o: 'gpt-4o',\n GPT_4o_MINI: 'gpt-4o-mini',\n GPT_4_TURBO: 'gpt-4-turbo',\n GPT_4: 'gpt-4',\n GPT_3_5_TURBO: 'gpt-3.5-turbo',\n} as const;\n\nexport type ChatGptModel = (typeof CHAT_GPT_MODELS)[keyof typeof CHAT_GPT_MODELS];\n"]}
1
+ {"version":3,"sources":["../src/client.ts","../src/operations/create-chat-completion.ts","../src/adapter.ts","../src/models.ts"],"names":["response"],"mappings":";;;;AAGO,IAAM,mBAAA,GAAsB,CAAC,MAAA,KAAkC;AAClE,EAAA,OAAO,IAAI,MAAA,CAAO;AAAA,IACd,QAAQ,MAAA,CAAO,MAAA;AAAA,IACf,cAAc,MAAA,CAAO,YAAA;AAAA,IACrB,SAAS,MAAA,CAAO;AAAA,GACnB,CAAA;AACL;ACNO,IAAM,oBAAA,GACT,CAAC,GAAA,KACD,OAAO,KAAA,KAA0E;AAC7E,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAS,GAAI,GAAA;AAErC,EAAA,MAAM,WAAA,GAAc;AAAA,IAChB,GAAG,QAAA;AAAA,IACH,GAAG;AAAA,GACP;AAEA,EAAA,IAAI,CAAC,YAAY,KAAA,EAAO;AACpB,IAAA,MAAM,IAAI,MAAM,kDAAkD,CAAA;AAAA,EACtE;AAEA,EAAA,MAAM,EAAE,MAAA,EAAQ,UAAA,EAAY,QAAA,EAAU,GAAG,MAAK,GAAI,WAAA;AAElD,EAAA,MAAA,EAAQ,KAAA,CAAM,qCAAA,EAAuC,EAAE,IAAA,EAAM,aAAa,CAAA;AAE1E,EAAA,IAAI;AACA,IAAA,IAAI,MAAA,EAAQ;AACR,MAAA,MAAMA,SAAAA,GAAW,MAAO,MAAA,CAAO,SAAA,CAAkB,KAAA,CAAM;AAAA,QACnD,GAAG,IAAA;AAAA,QACH,KAAA,EAAO,QAAA;AAAA,QACP,IAAA,EAAM;AAAA,UACF,MAAA,EAAQ,aAAA,CAAc,MAAA,EAAQ,UAAA,IAAc,QAAQ;AAAA;AACxD,OACH,CAAA;AAED,MAAA,MAAA,EAAQ,KAAA,CAAM,uCAAA,EAAyC,EAAE,IAAA,EAAMA,WAAU,CAAA;AAEzE,MAAA,OAAO;AAAA,QACH,GAAGA,SAAAA;AAAA,QACH,QAAQA,SAAAA,CAAS;AAAA,OACrB;AAAA,IACJ;AAIA,IAAA,MAAM,QAAA,GAAW,MAAM,MAAA,CAAO,IAAA,CAAK,YAAY,MAAA,CAAO;AAAA,MAClD,GAAG;AAAA,KACC,CAAA;AAER,IAAA,MAAA,EAAQ,KAAA,CAAM,uCAAA,EAAyC,EAAE,IAAA,EAAM,UAAU,CAAA;AAEzE,IAAA,OAAO,QAAA;AAAA,EACX,SAAS,KAAA,EAAO;AACZ,IAAA,MAAA,EAAQ,KAAA,CAAM,qCAAA,EAAuC,EAAE,KAAA,EAAO,CAAA;AAC9D,IAAA,MAAM,KAAA;AAAA,EACV;AACJ;;;AC3CG,IAAM,aAAA,GAAgB,CAAC,MAAA,EAAuB,MAAA,KAAoC;AACrF,EAAA,MAAM,MAAA,GAAS,oBAAoB,MAAM,CAAA;AACzC,EAAA,MAAM,UAA0B,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAU,OAAO,QAAA,EAAS;AAE5E,EAAA,OAAO;AAAA,IACH,oBAAA,EAAsB,qBAAqB,OAAO;AAAA,GACtD;AACJ;;;AChBO,IAAM,eAAA,GAAkB;AAAA,EAC3B,MAAA,EAAQ,QAAA;AAAA,EACR,iBAAA,EAAmB,mBAAA;AAAA,EACnB,WAAA,EAAa,aAAA;AAAA,EACb,sBAAA,EAAwB,wBAAA;AAAA,EACxB,WAAA,EAAa,aAAA;AAAA,EACb,KAAA,EAAO,OAAA;AAAA,EACP,aAAA,EAAe;AACnB","file":"index.mjs","sourcesContent":["import OpenAI from 'openai';\nimport { ChatGptConfig } from './types';\n\nexport const createChatGptClient = (config: ChatGptConfig): OpenAI => {\n return new OpenAI({\n apiKey: config.apiKey,\n organization: config.organization,\n project: config.project,\n });\n};\n","import { zodTextFormat } from 'openai/helpers/zod';\nimport { ChatGptContext, CreateChatCompletionInput, CreateChatCompletionOutput } from '../types';\n\nexport const createChatCompletion =\n (ctx: ChatGptContext) =>\n async (input: CreateChatCompletionInput): Promise<CreateChatCompletionOutput> => {\n const { client, logger, defaults } = ctx;\n\n const mergedInput = {\n ...defaults,\n ...input,\n };\n\n if (!mergedInput.model) {\n throw new Error('chat-gpt:createChatCompletion: model is required');\n }\n\n const { schema, schemaName, messages, ...rest } = mergedInput;\n\n logger?.debug('chat-gpt:createChatCompletion:start', { data: mergedInput });\n\n try {\n if (schema) {\n const response = await (client.responses as any).parse({\n ...rest,\n input: messages,\n text: {\n format: zodTextFormat(schema, schemaName || 'output'),\n },\n });\n\n logger?.debug('chat-gpt:createChatCompletion:success', { data: response });\n\n return {\n ...response,\n parsed: response.output_parsed,\n } as CreateChatCompletionOutput;\n }\n\n // Fallback to regular chat completion for non-zod calls\n // or we can use client.responses.create if we want to be consistent\n const response = await client.chat.completions.create({\n ...mergedInput,\n } as any);\n\n logger?.debug('chat-gpt:createChatCompletion:success', { data: response });\n\n return response as CreateChatCompletionOutput;\n } catch (error) {\n logger?.debug('chat-gpt:createChatCompletion:error', { error });\n throw error;\n }\n };\n","import OpenAI from 'openai';\nimport { ChatGptConfig, ChatGptContext, Logger } from './types';\nimport { createChatGptClient } from './client';\nimport { createChatCompletion } from './operations/create-chat-completion';\n\nexport interface ChatGptAdapter {\n createChatCompletion: ReturnType<typeof createChatCompletion>;\n}\n\nexport const createAdapter = (config: ChatGptConfig, logger?: Logger): ChatGptAdapter => {\n const client = createChatGptClient(config);\n const context: ChatGptContext = { client, logger, defaults: config.defaults };\n\n return {\n createChatCompletion: createChatCompletion(context),\n };\n};\n","export const CHAT_GPT_MODELS = {\n GPT_4o: 'gpt-4o',\n GPT_4o_2024_08_06: 'gpt-4o-2024-08-06',\n GPT_4o_MINI: 'gpt-4o-mini',\n GPT_4o_MINI_2024_07_18: 'gpt-4o-mini-2024-07-18',\n GPT_4_TURBO: 'gpt-4-turbo',\n GPT_4: 'gpt-4',\n GPT_3_5_TURBO: 'gpt-3.5-turbo',\n} as const;\n\nexport type ChatGptModel = (typeof CHAT_GPT_MODELS)[keyof typeof CHAT_GPT_MODELS];\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitkuz/vitkuz-chat-gpt-apapter",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",