@holokai/holo-provider-openai 0.1.1 → 0.1.3

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,8 +1,9 @@
1
- import { IResponseFactory } from "@holokai/sdk";
1
+ import { HoloErrorCode, IResponseFactory } from "@holokai/sdk";
2
2
  import { ResponseErrorEvent } from "openai/resources/responses/responses";
3
3
  export type OpenAIResponseCode = 'server_error' | 'rate_limit_exceeded' | 'invalid_prompt' | 'vector_store_timeout' | 'invalid_image' | 'invalid_image_format' | 'invalid_base64_image' | 'invalid_image_url' | 'image_too_large' | 'image_too_small' | 'image_parse_error' | 'image_content_policy_violation' | 'invalid_image_mode' | 'image_file_too_large' | 'unsupported_image_media_type' | 'empty_image_file' | 'failed_to_download_image' | 'image_file_not_found';
4
4
  export declare class OpenAIResponseFactory implements IResponseFactory {
5
- createError(message: string, code?: OpenAIResponseCode): ResponseErrorEvent;
5
+ mapHoloCode(code: HoloErrorCode): OpenAIResponseCode;
6
+ createError(message: string, code: HoloErrorCode): ResponseErrorEvent;
6
7
  static instance(): OpenAIResponseFactory;
7
8
  }
8
9
  //# sourceMappingURL=openai.response.factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai.response.factory.d.ts","sourceRoot":"","sources":["../src/openai.response.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAExE,MAAM,MAAM,kBAAkB,GAAK,cAAc,GAC3C,qBAAqB,GACrB,gBAAgB,GAChB,sBAAsB,GACtB,eAAe,GACf,sBAAsB,GACtB,sBAAsB,GACtB,mBAAmB,GACnB,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,gCAAgC,GAChC,oBAAoB,GACpB,sBAAsB,GACtB,8BAA8B,GAC9B,kBAAkB,GAClB,0BAA0B,GAC1B,sBAAsB,CAAC;AAE7B,qBAAa,qBAAsB,YAAW,gBAAgB;IAC1D,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAqC,GAAG,kBAAkB;IAU7F,MAAM,CAAC,QAAQ,IAAI,qBAAqB;CAG3C"}
1
+ {"version":3,"file":"openai.response.factory.d.ts","sourceRoot":"","sources":["../src/openai.response.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAExE,MAAM,MAAM,kBAAkB,GAAK,cAAc,GAC3C,qBAAqB,GACrB,gBAAgB,GAChB,sBAAsB,GACtB,eAAe,GACf,sBAAsB,GACtB,sBAAsB,GACtB,mBAAmB,GACnB,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,gCAAgC,GAChC,oBAAoB,GACpB,sBAAsB,GACtB,8BAA8B,GAC9B,kBAAkB,GAClB,0BAA0B,GAC1B,sBAAsB,CAAC;AAE7B,qBAAa,qBAAsB,YAAW,gBAAgB;IAC1D,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,kBAAkB;IASpD,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,kBAAkB;IAUrE,MAAM,CAAC,QAAQ,IAAI,qBAAqB;CAG3C"}
@@ -1,10 +1,18 @@
1
1
  export class OpenAIResponseFactory {
2
- createError(message, code = 'invalid_prompt') {
2
+ mapHoloCode(code) {
3
+ switch (code) {
4
+ case 'guard_failure':
5
+ return 'invalid_prompt';
6
+ default:
7
+ return 'invalid_prompt';
8
+ }
9
+ }
10
+ createError(message, code) {
3
11
  return {
4
12
  type: 'error',
5
13
  message,
6
14
  param: null,
7
- code,
15
+ code: this.mapHoloCode(code),
8
16
  sequence_number: 0
9
17
  };
10
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"openai.response.factory.js","sourceRoot":"","sources":["../src/openai.response.factory.ts"],"names":[],"mappings":"AAsBA,MAAM,OAAO,qBAAqB;IAC9B,WAAW,CAAC,OAAe,EAAE,OAA2B,gBAAgB;QACpE,OAAO;YACH,IAAI,EAAE,OAAO;YACb,OAAO;YACP,KAAK,EAAE,IAAI;YACX,IAAI;YACJ,eAAe,EAAE,CAAC;SACrB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,QAAQ;QACX,OAAO,IAAI,qBAAqB,EAAE,CAAC;IACvC,CAAC;CACJ"}
1
+ {"version":3,"file":"openai.response.factory.js","sourceRoot":"","sources":["../src/openai.response.factory.ts"],"names":[],"mappings":"AAsBA,MAAM,OAAO,qBAAqB;IAC9B,WAAW,CAAC,IAAmB;QAC3B,QAAQ,IAAI,EAAE,CAAC;YACX,KAAK,eAAe;gBAChB,OAAO,gBAAgB,CAAC;YAC5B;gBACI,OAAO,gBAAgB,CAAC;QAChC,CAAC;IACL,CAAC;IAED,WAAW,CAAC,OAAe,EAAE,IAAmB;QAC5C,OAAO;YACH,IAAI,EAAE,OAAO;YACb,OAAO;YACP,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YAC5B,eAAe,EAAE,CAAC;SACrB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,QAAQ;QACX,OAAO,IAAI,qBAAqB,EAAE,CAAC;IACvC,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holokai/holo-provider-openai",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "OpenAI provider plugin for Holo LLM Gateway",
6
6
  "author": "Holokai",
@@ -58,7 +58,7 @@
58
58
  "prepublishOnly": "npm run clean && npm run build"
59
59
  },
60
60
  "peerDependencies": {
61
- "@holokai/sdk": "^0.1.1"
61
+ "@holokai/sdk": "^0.1.3"
62
62
  },
63
63
  "dependencies": {
64
64
  "openai": "^6.17.0"