@nu-art/ts-openai-frontend 0.401.9 → 0.500.0

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,31 +1,12 @@
1
- import { AppToolsScreen, ComponentSync } from '@nu-art/thunderstorm-frontend/index';
2
- type ATS_OpenAI_Props = {};
1
+ import * as React from 'react';
2
+ import './ATS_OpenAI.scss';
3
+ type ATS_OpenAI_Props = Record<string, never>;
3
4
  type ATS_OpenAI_State = {
4
5
  directive: string;
5
6
  input: string;
6
7
  output?: string;
7
8
  };
8
- /**
9
- * in this example the backend config should be something of this sort:
10
- *
11
- * ```
12
- * {
13
- * directives: {
14
- * 'address-resolver': 'You are a Typescript address resolving assistant, you return a JSON with the following props: city, streetName, houseNumber, entrance (single letter), floor, apartmentNumber, country and additionalInfo. The JSON props must remain in english whereas the values need to be translated to valid addresses in Hebrew. unavailable props should be omitted from the JSON\'s props',
15
- * },
16
- * defaultModel: 'gpt-4',
17
- * apiKey: 'YourAPI-Key',
18
- * orgId: 'YourORG-Id'
19
- * }
20
- * ```
21
- */
22
- export declare class ATS_OpenAI extends ComponentSync<ATS_OpenAI_Props, ATS_OpenAI_State> {
23
- static screen: AppToolsScreen;
24
- static defaultProps: {
25
- modules: never[];
26
- pageTitle: () => string;
27
- };
28
- protected deriveStateFromProps(nextProps: ATS_OpenAI_Props, state?: ATS_OpenAI_State): ATS_OpenAI_State;
9
+ export declare class ATS_OpenAI extends React.Component<ATS_OpenAI_Props, ATS_OpenAI_State> {
29
10
  constructor(p: ATS_OpenAI_Props);
30
11
  render(): import("react/jsx-runtime").JSX.Element;
31
12
  private sendRequest;
@@ -1,33 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ATS_3rd_Party, Button, ComponentSync, LL_H_C, LL_H_T, LL_V_L } from '@nu-art/thunderstorm-frontend/index';
3
- import { TS_TextAreaV2 } from '@nu-art/thunderstorm-frontend/components/TS_V2_TextArea/index';
2
+ import * as React from 'react';
4
3
  import { ModuleFE_OpenAI } from '../modules/ModuleFE_OpenAI.js';
5
4
  import { __stringify } from '@nu-art/ts-common';
6
- /**
7
- * in this example the backend config should be something of this sort:
8
- *
9
- * ```
10
- * {
11
- * directives: {
12
- * 'address-resolver': 'You are a Typescript address resolving assistant, you return a JSON with the following props: city, streetName, houseNumber, entrance (single letter), floor, apartmentNumber, country and additionalInfo. The JSON props must remain in english whereas the values need to be translated to valid addresses in Hebrew. unavailable props should be omitted from the JSON\'s props',
13
- * },
14
- * defaultModel: 'gpt-4',
15
- * apiKey: 'YourAPI-Key',
16
- * orgId: 'YourORG-Id'
17
- * }
18
- * ```
19
- */
20
- export class ATS_OpenAI extends ComponentSync {
21
- static screen = { name: `OpenAI`, renderer: this, group: ATS_3rd_Party };
22
- static defaultProps = {
23
- modules: [],
24
- pageTitle: () => this.screen.name
25
- };
26
- deriveStateFromProps(nextProps, state = {}) {
27
- return { output: undefined, input: '', directive: '' };
28
- }
5
+ import './ATS_OpenAI.scss';
6
+ export class ATS_OpenAI extends React.Component {
29
7
  constructor(p) {
30
8
  super(p);
9
+ this.state = { directive: '', input: '' };
31
10
  }
32
11
  render() {
33
12
  let value = this.state.output;
@@ -35,19 +14,17 @@ export class ATS_OpenAI extends ComponentSync {
35
14
  if (value)
36
15
  value = __stringify(JSON.parse(value), true);
37
16
  }
38
- catch (e) {
17
+ catch {
39
18
  // not a pure json response
40
19
  }
41
- this.logInfo(value);
42
- return _jsxs(LL_H_T, { children: [_jsxs(LL_V_L, { children: ["App dev screen for OpenAI", _jsx(Button, { onClick: this.sendRequest, children: "Test" })] }), _jsxs(LL_V_L, { children: [_jsx(TS_TextAreaV2, { className: 'ts-textarea', style: { width: 1008, height: 200, marginBottom: 8, fontFamily: 'monospace', fontSize: 15 }, value: this.state.directive, onChange: (value) => this.setState({ directive: value }) }), _jsxs(LL_H_C, { children: [_jsx(TS_TextAreaV2, { className: 'ts-textarea', style: { width: 500, height: 500, marginRight: 8, fontFamily: 'monospace', fontSize: 15 }, value: this.state.input, onChange: (value) => this.setState({ input: value }) }), _jsx(TS_TextAreaV2, { className: 'ts-textarea', style: { width: 500, height: 500, fontFamily: 'monospace', fontSize: 15 }, disabled: true, value: value })] })] })] });
20
+ return (_jsxs("div", { className: "ats-openai", children: [_jsxs("div", { className: "ats-openai__section", children: ["App dev screen for OpenAI", _jsx("button", { type: "button", onClick: this.sendRequest, children: "Test" })] }), _jsxs("div", { className: "ats-openai__section", children: [_jsx("textarea", { className: "ats-openai__textarea", style: { width: 1008, height: 200, marginBottom: 8, fontFamily: 'monospace', fontSize: 15 }, value: this.state.directive, onChange: e => this.setState({ directive: e.target.value }) }), _jsxs("div", { className: "ats-openai__row", children: [_jsx("textarea", { className: "ats-openai__textarea", style: { width: 500, height: 500, marginRight: 8, fontFamily: 'monospace', fontSize: 15 }, value: this.state.input, onChange: e => this.setState({ input: e.target.value }) }), _jsx("textarea", { className: "ats-openai__textarea", style: { width: 500, height: 500, fontFamily: 'monospace', fontSize: 15 }, readOnly: true, value: value ?? '' })] })] })] }));
43
21
  }
44
- sendRequest = async (e) => {
22
+ sendRequest = async (_e) => {
45
23
  this.setState({ output: undefined });
46
- const response = await ModuleFE_OpenAI.v1.test({
24
+ const response = await ModuleFE_OpenAI.test({
47
25
  directive: this.state.directive,
48
- message: this.state.input
49
- }).executeSync();
50
- this.logWarning(response);
26
+ message: this.state.input,
27
+ });
51
28
  this.setState({ output: response.response });
52
29
  };
53
30
  }
@@ -1,2 +1,22 @@
1
- .ts-ats.ats-OpenAI {
2
- }
1
+ .ats-openai {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 1rem;
5
+ }
6
+
7
+ .ats-openai__section {
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: 0.5rem;
11
+ }
12
+
13
+ .ats-openai__row {
14
+ display: flex;
15
+ flex-direction: row;
16
+ gap: 0.5rem;
17
+ }
18
+
19
+ .ats-openai__textarea {
20
+ box-sizing: border-box;
21
+ resize: none;
22
+ }
@@ -1,11 +1,10 @@
1
1
  import { Module } from '@nu-art/ts-common';
2
- import { ApiDefCaller } from '@nu-art/thunderstorm-shared';
3
- import { ApiStruct_OpenAI } from '@nu-art/ts-openai-shared/api-def';
4
- type Config = {};
2
+ import { API_OpenAI } from '@nu-art/ts-openai-shared/api-def';
3
+ type Config = Record<string, never>;
5
4
  export declare class ModuleFE_OpenAI_Class extends Module<Config> {
6
- readonly v1: ApiDefCaller<ApiStruct_OpenAI>['v1'];
7
5
  constructor();
8
- init(): void;
6
+ protected init(): void;
7
+ test(body: API_OpenAI['test']['Body']): Promise<API_OpenAI['test']['Response']>;
9
8
  }
10
9
  export declare const ModuleFE_OpenAI: ModuleFE_OpenAI_Class;
11
10
  export {};
@@ -1,15 +1,62 @@
1
- import { Module } from '@nu-art/ts-common';
2
- import { apiWithBody } from '@nu-art/thunderstorm-frontend/index';
3
- import { ApiDef_OpenAI } from '@nu-art/ts-openai-shared/api-def';
4
- export class ModuleFE_OpenAI_Class extends Module {
5
- v1;
6
- constructor() {
7
- super();
8
- this.v1 = {
9
- test: apiWithBody(ApiDef_OpenAI.v1.test),
10
- };
1
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
2
+ var useValue = arguments.length > 2;
3
+ for (var i = 0; i < initializers.length; i++) {
4
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
11
5
  }
12
- init() {
6
+ return useValue ? value : void 0;
7
+ };
8
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
9
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
10
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
11
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
12
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
13
+ var _, done = false;
14
+ for (var i = decorators.length - 1; i >= 0; i--) {
15
+ var context = {};
16
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
17
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
18
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
19
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
20
+ if (kind === "accessor") {
21
+ if (result === void 0) continue;
22
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
23
+ if (_ = accept(result.get)) descriptor.get = _;
24
+ if (_ = accept(result.set)) descriptor.set = _;
25
+ if (_ = accept(result.init)) initializers.unshift(_);
26
+ }
27
+ else if (_ = accept(result)) {
28
+ if (kind === "field") initializers.unshift(_);
29
+ else descriptor[key] = _;
30
+ }
13
31
  }
14
- }
32
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
33
+ done = true;
34
+ };
35
+ import { Module } from '@nu-art/ts-common';
36
+ import { ApiCaller } from '@nu-art/http-client';
37
+ import { ApiDef_OpenAI } from '@nu-art/ts-openai-shared/api-def';
38
+ let ModuleFE_OpenAI_Class = (() => {
39
+ let _classSuper = Module;
40
+ let _instanceExtraInitializers = [];
41
+ let _test_decorators;
42
+ return class ModuleFE_OpenAI_Class extends _classSuper {
43
+ static {
44
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
45
+ _test_decorators = [ApiCaller(ApiDef_OpenAI.test)];
46
+ __esDecorate(this, null, _test_decorators, { kind: "method", name: "test", static: false, private: false, access: { has: obj => "test" in obj, get: obj => obj.test }, metadata: _metadata }, null, _instanceExtraInitializers);
47
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
48
+ }
49
+ constructor() {
50
+ super();
51
+ __runInitializers(this, _instanceExtraInitializers);
52
+ }
53
+ init() {
54
+ }
55
+ async test(body) {
56
+ void body;
57
+ return undefined;
58
+ }
59
+ };
60
+ })();
61
+ export { ModuleFE_OpenAI_Class };
15
62
  export const ModuleFE_OpenAI = new ModuleFE_OpenAI_Class();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/ts-openai-frontend",
3
- "version": "0.401.9",
3
+ "version": "0.500.0",
4
4
  "description": "ts-openai - Express & Typescript based backend framework",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -31,10 +31,9 @@
31
31
  "build": "tsc"
32
32
  },
33
33
  "dependencies": {
34
- "@nu-art/ts-common": "0.401.9",
35
- "@nu-art/thunderstorm-frontend": "0.401.9",
36
- "@nu-art/thunderstorm-shared": "0.401.9",
37
- "@nu-art/ts-openai-shared": "0.401.9",
34
+ "@nu-art/ts-common": "0.500.0",
35
+ "@nu-art/http-client": "{{THUNDERSTORM_VERSION}}",
36
+ "@nu-art/ts-openai-shared": "0.500.0",
38
37
  "openai": "^6.7.0",
39
38
  "firebase": "^11.9.0",
40
39
  "firebase-admin": "13.4.0",