@umituz/react-native-ai-groq-provider 1.0.3 → 1.0.4

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.
Files changed (93) hide show
  1. package/dist/domain/entities/error.types.d.ts +34 -0
  2. package/dist/domain/entities/error.types.d.ts.map +1 -0
  3. package/dist/domain/entities/error.types.js +57 -0
  4. package/dist/domain/entities/error.types.js.map +1 -0
  5. package/dist/domain/entities/groq.types.d.ts +222 -0
  6. package/dist/domain/entities/groq.types.d.ts.map +1 -0
  7. package/dist/domain/entities/groq.types.js +37 -0
  8. package/dist/domain/entities/groq.types.js.map +1 -0
  9. package/dist/domain/entities/index.d.ts +7 -0
  10. package/dist/domain/entities/index.d.ts.map +1 -0
  11. package/dist/domain/entities/index.js +23 -0
  12. package/dist/domain/entities/index.js.map +1 -0
  13. package/dist/domain/entities/models.d.ts +50 -0
  14. package/dist/domain/entities/models.d.ts.map +1 -0
  15. package/dist/domain/entities/models.js +178 -0
  16. package/dist/domain/entities/models.js.map +1 -0
  17. package/dist/index.d.ts +27 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +73 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/infrastructure/services/ChatSession.d.ts +95 -0
  22. package/dist/infrastructure/services/ChatSession.d.ts.map +1 -0
  23. package/dist/infrastructure/services/ChatSession.js +177 -0
  24. package/dist/infrastructure/services/ChatSession.js.map +1 -0
  25. package/dist/infrastructure/services/GroqClient.d.ts +52 -0
  26. package/dist/infrastructure/services/GroqClient.d.ts.map +1 -0
  27. package/dist/infrastructure/services/GroqClient.js +205 -0
  28. package/dist/infrastructure/services/GroqClient.js.map +1 -0
  29. package/dist/infrastructure/services/Streaming.d.ts +27 -0
  30. package/dist/infrastructure/services/Streaming.d.ts.map +1 -0
  31. package/dist/infrastructure/services/Streaming.js +84 -0
  32. package/dist/infrastructure/services/Streaming.js.map +1 -0
  33. package/dist/infrastructure/services/StructuredText.d.ts +20 -0
  34. package/dist/infrastructure/services/StructuredText.d.ts.map +1 -0
  35. package/dist/infrastructure/services/StructuredText.js +122 -0
  36. package/dist/infrastructure/services/StructuredText.js.map +1 -0
  37. package/dist/infrastructure/services/TextGeneration.d.ts +18 -0
  38. package/dist/infrastructure/services/TextGeneration.d.ts.map +1 -0
  39. package/dist/infrastructure/services/TextGeneration.js +64 -0
  40. package/dist/infrastructure/services/TextGeneration.js.map +1 -0
  41. package/dist/infrastructure/services/index.d.ts +9 -0
  42. package/dist/infrastructure/services/index.d.ts.map +1 -0
  43. package/dist/infrastructure/services/index.js +24 -0
  44. package/dist/infrastructure/services/index.js.map +1 -0
  45. package/dist/infrastructure/telemetry/TelemetryHooks.d.ts +48 -0
  46. package/dist/infrastructure/telemetry/TelemetryHooks.d.ts.map +1 -0
  47. package/dist/infrastructure/telemetry/TelemetryHooks.js +70 -0
  48. package/dist/infrastructure/telemetry/TelemetryHooks.js.map +1 -0
  49. package/dist/infrastructure/telemetry/index.d.ts +5 -0
  50. package/dist/infrastructure/telemetry/index.d.ts.map +1 -0
  51. package/dist/infrastructure/telemetry/index.js +10 -0
  52. package/dist/infrastructure/telemetry/index.js.map +1 -0
  53. package/dist/infrastructure/utils/async/execute-state.util.d.ts +27 -0
  54. package/dist/infrastructure/utils/async/execute-state.util.d.ts.map +1 -0
  55. package/dist/infrastructure/utils/async/execute-state.util.js +50 -0
  56. package/dist/infrastructure/utils/async/execute-state.util.js.map +1 -0
  57. package/dist/infrastructure/utils/async/index.d.ts +6 -0
  58. package/dist/infrastructure/utils/async/index.d.ts.map +1 -0
  59. package/dist/infrastructure/utils/async/index.js +10 -0
  60. package/dist/infrastructure/utils/async/index.js.map +1 -0
  61. package/dist/infrastructure/utils/content-mapper.util.d.ts +34 -0
  62. package/dist/infrastructure/utils/content-mapper.util.d.ts.map +1 -0
  63. package/dist/infrastructure/utils/content-mapper.util.js +84 -0
  64. package/dist/infrastructure/utils/content-mapper.util.js.map +1 -0
  65. package/dist/infrastructure/utils/error-mapper.util.d.ts +21 -0
  66. package/dist/infrastructure/utils/error-mapper.util.d.ts.map +1 -0
  67. package/dist/infrastructure/utils/error-mapper.util.js +73 -0
  68. package/dist/infrastructure/utils/error-mapper.util.js.map +1 -0
  69. package/dist/infrastructure/utils/index.d.ts +7 -0
  70. package/dist/infrastructure/utils/index.d.ts.map +1 -0
  71. package/dist/infrastructure/utils/index.js +23 -0
  72. package/dist/infrastructure/utils/index.js.map +1 -0
  73. package/dist/presentation/hooks/useGroq.d.ts +42 -0
  74. package/dist/presentation/hooks/useGroq.d.ts.map +1 -0
  75. package/dist/presentation/hooks/useGroq.js +153 -0
  76. package/dist/presentation/hooks/useGroq.js.map +1 -0
  77. package/dist/presentation/hooks/useOperationManager.d.ts +34 -0
  78. package/dist/presentation/hooks/useOperationManager.d.ts.map +1 -0
  79. package/dist/presentation/hooks/useOperationManager.js +76 -0
  80. package/dist/presentation/hooks/useOperationManager.js.map +1 -0
  81. package/dist/providers/ConfigBuilder.d.ts +86 -0
  82. package/dist/providers/ConfigBuilder.d.ts.map +1 -0
  83. package/dist/providers/ConfigBuilder.js +147 -0
  84. package/dist/providers/ConfigBuilder.js.map +1 -0
  85. package/dist/providers/ProviderFactory.d.ts +56 -0
  86. package/dist/providers/ProviderFactory.d.ts.map +1 -0
  87. package/dist/providers/ProviderFactory.js +75 -0
  88. package/dist/providers/ProviderFactory.js.map +1 -0
  89. package/dist/providers/index.d.ts +7 -0
  90. package/dist/providers/index.d.ts.map +1 -0
  91. package/dist/providers/index.js +15 -0
  92. package/dist/providers/index.js.map +1 -0
  93. package/package.json +1 -1
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ /**
3
+ * useOperationManager Hook
4
+ * Manages async operations with loading, error, and success states
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useOperationManager = useOperationManager;
8
+ const react_1 = require("react");
9
+ const error_mapper_util_1 = require("../../infrastructure/utils/error-mapper.util");
10
+ const telemetry_1 = require("../../infrastructure/telemetry");
11
+ /**
12
+ * Hook for managing async operations
13
+ */
14
+ function useOperationManager(options = {}) {
15
+ const [state, setState] = (0, react_1.useState)({
16
+ isLoading: false,
17
+ error: null,
18
+ data: options.initialData ?? null,
19
+ });
20
+ const abortControllerRef = (0, react_1.useRef)(null);
21
+ const operationNameRef = (0, react_1.useRef)("");
22
+ const execute = (0, react_1.useCallback)(async (operationName, asyncFn, config) => {
23
+ // Cancel previous operation if configured
24
+ if (config?.abortPrevious && abortControllerRef.current) {
25
+ abortControllerRef.current.abort();
26
+ }
27
+ abortControllerRef.current = new AbortController();
28
+ operationNameRef.current = operationName;
29
+ setState((prev) => ({ ...prev, isLoading: true, error: null }));
30
+ telemetry_1.telemetry.log(`${operationName}_start`);
31
+ options.onStart?.();
32
+ try {
33
+ const result = await asyncFn(abortControllerRef.current.signal);
34
+ setState((prev) => ({ ...prev, isLoading: false, data: result }));
35
+ options.onSuccess?.(result);
36
+ telemetry_1.telemetry.log(`${operationName}_success`);
37
+ return result;
38
+ }
39
+ catch (error) {
40
+ const errorMessage = (0, error_mapper_util_1.getUserFriendlyError)(error);
41
+ setState((prev) => ({ ...prev, isLoading: false, error: errorMessage }));
42
+ options.onError?.(errorMessage);
43
+ telemetry_1.telemetry.log(`${operationName}_error`, { error: errorMessage });
44
+ throw error;
45
+ }
46
+ finally {
47
+ abortControllerRef.current = null;
48
+ }
49
+ }, [options]);
50
+ const reset = (0, react_1.useCallback)(() => {
51
+ if (abortControllerRef.current) {
52
+ abortControllerRef.current.abort();
53
+ abortControllerRef.current = null;
54
+ }
55
+ setState((prev) => ({
56
+ ...prev,
57
+ isLoading: false,
58
+ error: null,
59
+ data: options.initialData ?? null,
60
+ }));
61
+ }, [options.initialData]);
62
+ const clearError = (0, react_1.useCallback)(() => {
63
+ setState((prev) => ({ ...prev, error: null }));
64
+ }, []);
65
+ const setData = (0, react_1.useCallback)((data) => {
66
+ setState((prev) => ({ ...prev, data }));
67
+ }, []);
68
+ return {
69
+ ...state,
70
+ execute,
71
+ reset,
72
+ clearError,
73
+ setData,
74
+ };
75
+ }
76
+ //# sourceMappingURL=useOperationManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOperationManager.js","sourceRoot":"","sources":["../../../src/presentation/hooks/useOperationManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA0BH,kDAgFC;AAxGD,iCAAsD;AACtD,oFAAoF;AACpF,8DAA2D;AAmB3D;;GAEG;AACH,SAAgB,mBAAmB,CACjC,UAAyC,EAAE;IAE3C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAoB;QACpD,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,OAAO,CAAC,WAAW,IAAI,IAAI;KAClC,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,IAAA,cAAM,EAAyB,IAAI,CAAC,CAAC;IAChE,MAAM,gBAAgB,GAAG,IAAA,cAAM,EAAS,EAAE,CAAC,CAAC;IAE5C,MAAM,OAAO,GAAG,IAAA,mBAAW,EACzB,KAAK,EACH,aAAqB,EACrB,OAA6C,EAC7C,MAAoC,EACxB,EAAE;QACd,0CAA0C;QAC1C,IAAI,MAAM,EAAE,aAAa,IAAI,kBAAkB,CAAC,OAAO,EAAE,CAAC;YACxD,kBAAkB,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrC,CAAC;QAED,kBAAkB,CAAC,OAAO,GAAG,IAAI,eAAe,EAAE,CAAC;QACnD,gBAAgB,CAAC,OAAO,GAAG,aAAa,CAAC;QAEzC,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAEhE,qBAAS,CAAC,GAAG,CAAC,GAAG,aAAa,QAAQ,CAAC,CAAC;QACxC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QA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AS,EAAE,KAAK;YAChB,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,OAAO,CAAC,WAAW,IAAI,IAAI;SAClC,CAAC,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAE1B,MAAM,UAAU,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAClC,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,CAAC,IAAc,EAAE,EAAE;QAC7C,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,GAAG,KAAK;QACR,OAAO;QACP,KAAK;QACL,UAAU;QACV,OAAO;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Configuration Builder
3
+ * Builder pattern for Groq configuration
4
+ */
5
+ import type { GroqConfig, GroqGenerationConfig } from "../domain/entities";
6
+ /**
7
+ * Builder for Groq configuration
8
+ */
9
+ export declare class ConfigBuilder {
10
+ private config;
11
+ /**
12
+ * Set API key
13
+ */
14
+ withApiKey(apiKey: string): ConfigBuilder;
15
+ /**
16
+ * Set base URL
17
+ */
18
+ withBaseUrl(baseUrl: string): ConfigBuilder;
19
+ /**
20
+ * Set timeout
21
+ */
22
+ withTimeout(timeoutMs: number): ConfigBuilder;
23
+ /**
24
+ * Set default text model
25
+ */
26
+ withTextModel(model: string): ConfigBuilder;
27
+ /**
28
+ * Build configuration
29
+ */
30
+ build(): GroqConfig;
31
+ /**
32
+ * Create a new builder instance
33
+ */
34
+ static create(): ConfigBuilder;
35
+ }
36
+ /**
37
+ * Builder for generation configuration
38
+ */
39
+ export declare class GenerationConfigBuilder {
40
+ private config;
41
+ /**
42
+ * Set temperature
43
+ */
44
+ withTemperature(temperature: number): GenerationConfigBuilder;
45
+ /**
46
+ * Set max tokens
47
+ */
48
+ withMaxTokens(maxTokens: number): GenerationConfigBuilder;
49
+ /**
50
+ * Set top P
51
+ */
52
+ withTopP(topP: number): GenerationConfigBuilder;
53
+ /**
54
+ * Set frequency penalty
55
+ */
56
+ withFrequencyPenalty(penalty: number): GenerationConfigBuilder;
57
+ /**
58
+ * Set presence penalty
59
+ */
60
+ withPresencePenalty(penalty: number): GenerationConfigBuilder;
61
+ /**
62
+ * Set stop sequences
63
+ */
64
+ withStop(stop: string[]): GenerationConfigBuilder;
65
+ /**
66
+ * Build configuration
67
+ */
68
+ build(): GroqGenerationConfig;
69
+ /**
70
+ * Create a new builder instance
71
+ */
72
+ static create(): GenerationConfigBuilder;
73
+ /**
74
+ * Create a balanced configuration
75
+ */
76
+ static balanced(): GenerationConfigBuilder;
77
+ /**
78
+ * Create a creative configuration
79
+ */
80
+ static creative(): GenerationConfigBuilder;
81
+ /**
82
+ * Create a precise configuration
83
+ */
84
+ static precise(): GenerationConfigBuilder;
85
+ }
86
+ //# sourceMappingURL=ConfigBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigBuilder.d.ts","sourceRoot":"","sources":["../../src/providers/ConfigBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG3E;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAA2B;IAEzC;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAKzC;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa;IAK3C;;OAEG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa;IAK7C;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa;IAK3C;;OAEG;IACH,KAAK,IAAI,UAAU;IAanB;;OAEG;IACH,MAAM,CAAC,MAAM,IAAI,aAAa;CAG/B;AAED;;GAEG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,MAAM,CAA4B;IAE1C;;OAEG;IACH,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,uBAAuB;IAK7D;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB;IAKzD;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB;IAK/C;;OAEG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB;IAK9D;;OAEG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB;IAK7D;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,uBAAuB;IAKjD;;OAEG;IACH,KAAK,IAAI,oBAAoB;IAI7B;;OAEG;IACH,MAAM,CAAC,MAAM,IAAI,uBAAuB;IAIxC;;OAEG;IACH,MAAM,CAAC,QAAQ,IAAI,uBAAuB;IAI1C;;OAEG;IACH,MAAM,CAAC,QAAQ,IAAI,uBAAuB;IAI1C;;OAEG;IACH,MAAM,CAAC,OAAO,IAAI,uBAAuB;CAG1C"}
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ /**
3
+ * Configuration Builder
4
+ * Builder pattern for Groq configuration
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.GenerationConfigBuilder = exports.ConfigBuilder = void 0;
8
+ const entities_1 = require("../domain/entities");
9
+ /**
10
+ * Builder for Groq configuration
11
+ */
12
+ class ConfigBuilder {
13
+ constructor() {
14
+ this.config = {};
15
+ }
16
+ /**
17
+ * Set API key
18
+ */
19
+ withApiKey(apiKey) {
20
+ this.config.apiKey = apiKey;
21
+ return this;
22
+ }
23
+ /**
24
+ * Set base URL
25
+ */
26
+ withBaseUrl(baseUrl) {
27
+ this.config.baseUrl = baseUrl;
28
+ return this;
29
+ }
30
+ /**
31
+ * Set timeout
32
+ */
33
+ withTimeout(timeoutMs) {
34
+ this.config.timeoutMs = timeoutMs;
35
+ return this;
36
+ }
37
+ /**
38
+ * Set default text model
39
+ */
40
+ withTextModel(model) {
41
+ this.config.textModel = model;
42
+ return this;
43
+ }
44
+ /**
45
+ * Build configuration
46
+ */
47
+ build() {
48
+ if (!this.config.apiKey) {
49
+ throw new Error("API key is required. Use withApiKey() to set it.");
50
+ }
51
+ return {
52
+ apiKey: this.config.apiKey,
53
+ baseUrl: this.config.baseUrl,
54
+ timeoutMs: this.config.timeoutMs,
55
+ textModel: this.config.textModel || entities_1.DEFAULT_MODELS.TEXT,
56
+ };
57
+ }
58
+ /**
59
+ * Create a new builder instance
60
+ */
61
+ static create() {
62
+ return new ConfigBuilder();
63
+ }
64
+ }
65
+ exports.ConfigBuilder = ConfigBuilder;
66
+ /**
67
+ * Builder for generation configuration
68
+ */
69
+ class GenerationConfigBuilder {
70
+ constructor() {
71
+ this.config = {};
72
+ }
73
+ /**
74
+ * Set temperature
75
+ */
76
+ withTemperature(temperature) {
77
+ this.config.temperature = temperature;
78
+ return this;
79
+ }
80
+ /**
81
+ * Set max tokens
82
+ */
83
+ withMaxTokens(maxTokens) {
84
+ this.config.maxTokens = maxTokens;
85
+ return this;
86
+ }
87
+ /**
88
+ * Set top P
89
+ */
90
+ withTopP(topP) {
91
+ this.config.topP = topP;
92
+ return this;
93
+ }
94
+ /**
95
+ * Set frequency penalty
96
+ */
97
+ withFrequencyPenalty(penalty) {
98
+ this.config.frequencyPenalty = penalty;
99
+ return this;
100
+ }
101
+ /**
102
+ * Set presence penalty
103
+ */
104
+ withPresencePenalty(penalty) {
105
+ this.config.presencePenalty = penalty;
106
+ return this;
107
+ }
108
+ /**
109
+ * Set stop sequences
110
+ */
111
+ withStop(stop) {
112
+ this.config.stop = stop;
113
+ return this;
114
+ }
115
+ /**
116
+ * Build configuration
117
+ */
118
+ build() {
119
+ return { ...this.config };
120
+ }
121
+ /**
122
+ * Create a new builder instance
123
+ */
124
+ static create() {
125
+ return new GenerationConfigBuilder();
126
+ }
127
+ /**
128
+ * Create a balanced configuration
129
+ */
130
+ static balanced() {
131
+ return new GenerationConfigBuilder().withTemperature(0.7);
132
+ }
133
+ /**
134
+ * Create a creative configuration
135
+ */
136
+ static creative() {
137
+ return new GenerationConfigBuilder().withTemperature(1.0);
138
+ }
139
+ /**
140
+ * Create a precise configuration
141
+ */
142
+ static precise() {
143
+ return new GenerationConfigBuilder().withTemperature(0.3);
144
+ }
145
+ }
146
+ exports.GenerationConfigBuilder = GenerationConfigBuilder;
147
+ //# sourceMappingURL=ConfigBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigBuilder.js","sourceRoot":"","sources":["../../src/providers/ConfigBuilder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iDAAoD;AAEpD;;GAEG;AACH,MAAa,aAAa;IAA1B;QACU,WAAM,GAAwB,EAAE,CAAC;IAwD3C,CAAC;IAtDC;;OAEG;IACH,UAAU,CAAC,MAAc;QACvB,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,OAAe;QACzB,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,SAAiB;QAC3B,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,KAAa;QACzB,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED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AAQ,CAAC,IAAc;QACrB,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK;QACH,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,uBAAuB,EAAE,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ;QACb,OAAO,IAAI,uBAAuB,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ;QACb,OAAO,IAAI,uBAAuB,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,OAAO;QACZ,OAAO,IAAI,uBAAuB,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;CACF;AArFD,0DAqFC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Provider Factory
3
+ * Factory for creating configured Groq provider instances
4
+ */
5
+ import { ConfigBuilder, GenerationConfigBuilder } from "./ConfigBuilder";
6
+ /**
7
+ * Provider configuration options
8
+ */
9
+ export interface ProviderConfig {
10
+ apiKey: string;
11
+ baseUrl?: string;
12
+ timeoutMs?: number;
13
+ defaultModel?: string;
14
+ }
15
+ /**
16
+ * Provider factory options
17
+ */
18
+ export interface ProviderFactoryOptions {
19
+ enableTelemetry?: boolean;
20
+ onError?: (error: Error) => void;
21
+ }
22
+ /**
23
+ * Initialize Groq provider with configuration
24
+ */
25
+ export declare function initializeProvider(config: ProviderConfig): void;
26
+ /**
27
+ * Provider factory - creates configured provider instances
28
+ */
29
+ export declare const providerFactory: {
30
+ /**
31
+ * Create a new provider instance
32
+ */
33
+ create(config: ProviderConfig): void;
34
+ /**
35
+ * Create provider from environment variables
36
+ */
37
+ fromEnv(): void;
38
+ /**
39
+ * Reset provider (clear configuration)
40
+ */
41
+ reset(): void;
42
+ /**
43
+ * Check if provider is initialized
44
+ */
45
+ isInitialized(): boolean;
46
+ };
47
+ /**
48
+ * Convenience function to initialize provider
49
+ */
50
+ export declare function configureProvider(config: ProviderConfig): void;
51
+ /**
52
+ * Convenience function to reset provider
53
+ */
54
+ export declare function resetProvider(): void;
55
+ export { ConfigBuilder, GenerationConfigBuilder };
56
+ //# sourceMappingURL=ProviderFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderFactory.d.ts","sourceRoot":"","sources":["../../src/providers/ProviderFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAO/D;AAED;;GAEG;AACH,eAAO,MAAM,eAAe;IAC1B;;OAEG;mBACY,cAAc,GAAG,IAAI;IAIpC;;OAEG;eACQ,IAAI;IAcf;;OAEG;aACM,IAAI;IAIb;;OAEG;qBACc,OAAO;CAGzB,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAE9D;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAGD,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,CAAC"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /**
3
+ * Provider Factory
4
+ * Factory for creating configured Groq provider instances
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.GenerationConfigBuilder = exports.ConfigBuilder = exports.providerFactory = void 0;
8
+ exports.initializeProvider = initializeProvider;
9
+ exports.configureProvider = configureProvider;
10
+ exports.resetProvider = resetProvider;
11
+ const GroqClient_1 = require("../infrastructure/services/GroqClient");
12
+ const ConfigBuilder_1 = require("./ConfigBuilder");
13
+ Object.defineProperty(exports, "ConfigBuilder", { enumerable: true, get: function () { return ConfigBuilder_1.ConfigBuilder; } });
14
+ Object.defineProperty(exports, "GenerationConfigBuilder", { enumerable: true, get: function () { return ConfigBuilder_1.GenerationConfigBuilder; } });
15
+ /**
16
+ * Initialize Groq provider with configuration
17
+ */
18
+ function initializeProvider(config) {
19
+ GroqClient_1.groqHttpClient.initialize({
20
+ apiKey: config.apiKey,
21
+ baseUrl: config.baseUrl,
22
+ timeoutMs: config.timeoutMs,
23
+ textModel: config.defaultModel,
24
+ });
25
+ }
26
+ /**
27
+ * Provider factory - creates configured provider instances
28
+ */
29
+ exports.providerFactory = {
30
+ /**
31
+ * Create a new provider instance
32
+ */
33
+ create(config) {
34
+ initializeProvider(config);
35
+ },
36
+ /**
37
+ * Create provider from environment variables
38
+ */
39
+ fromEnv() {
40
+ const apiKey = process.env.GROQ_API_KEY;
41
+ if (!apiKey) {
42
+ throw new Error("GROQ_API_KEY environment variable is not set");
43
+ }
44
+ initializeProvider({
45
+ apiKey,
46
+ baseUrl: process.env.GROQ_BASE_URL,
47
+ timeoutMs: process.env.GROQ_TIMEOUT_MS ? parseInt(process.env.GROQ_TIMEOUT_MS) : undefined,
48
+ });
49
+ },
50
+ /**
51
+ * Reset provider (clear configuration)
52
+ */
53
+ reset() {
54
+ GroqClient_1.groqHttpClient.reset();
55
+ },
56
+ /**
57
+ * Check if provider is initialized
58
+ */
59
+ isInitialized() {
60
+ return GroqClient_1.groqHttpClient.isInitialized();
61
+ },
62
+ };
63
+ /**
64
+ * Convenience function to initialize provider
65
+ */
66
+ function configureProvider(config) {
67
+ exports.providerFactory.create(config);
68
+ }
69
+ /**
70
+ * Convenience function to reset provider
71
+ */
72
+ function resetProvider() {
73
+ exports.providerFactory.reset();
74
+ }
75
+ //# sourceMappingURL=ProviderFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderFactory.js","sourceRoot":"","sources":["../../src/providers/ProviderFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA2BH,gDAOC;AAgDD,8CAEC;AAKD,sCAEC;AAxFD,sEAAuE;AACvE,mDAAyE;AA0FhE,8FA1FA,6BAAa,OA0FA;AAAE,wGA1FA,uCAAuB,OA0FA;AAtE/C;;GAEG;AACH,SAAgB,kBAAkB,CAAC,MAAsB;IACvD,2BAAc,CAAC,UAAU,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,SAAS,EAAE,MAAM,CAAC,YAAY;KAC/B,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACU,QAAA,eAAe,GAAG;IAC7B;;OAEG;IACH,MAAM,CAAC,MAAsB;QAC3B,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,OAAO;QACL,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;QAExC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAAC;QAED,kBAAkB,CAAC;YACjB,MAAM;YACN,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;YAClC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS;SAC3F,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK;QACH,2BAAc,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,2BAAc,CAAC,aAAa,EAAE,CAAC;IACxC,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,SAAgB,iBAAiB,CAAC,MAAsB;IACtD,uBAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa;IAC3B,uBAAe,CAAC,KAAK,EAAE,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Providers
3
+ */
4
+ export { ConfigBuilder, GenerationConfigBuilder } from "./ConfigBuilder";
5
+ export { providerFactory, initializeProvider, configureProvider, resetProvider, } from "./ProviderFactory";
6
+ export type { ProviderConfig, ProviderFactoryOptions, } from "./ProviderFactory";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,cAAc,EACd,sBAAsB,GACvB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * Providers
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resetProvider = exports.configureProvider = exports.initializeProvider = exports.providerFactory = exports.GenerationConfigBuilder = exports.ConfigBuilder = void 0;
7
+ var ConfigBuilder_1 = require("./ConfigBuilder");
8
+ Object.defineProperty(exports, "ConfigBuilder", { enumerable: true, get: function () { return ConfigBuilder_1.ConfigBuilder; } });
9
+ Object.defineProperty(exports, "GenerationConfigBuilder", { enumerable: true, get: function () { return ConfigBuilder_1.GenerationConfigBuilder; } });
10
+ var ProviderFactory_1 = require("./ProviderFactory");
11
+ Object.defineProperty(exports, "providerFactory", { enumerable: true, get: function () { return ProviderFactory_1.providerFactory; } });
12
+ Object.defineProperty(exports, "initializeProvider", { enumerable: true, get: function () { return ProviderFactory_1.initializeProvider; } });
13
+ Object.defineProperty(exports, "configureProvider", { enumerable: true, get: function () { return ProviderFactory_1.configureProvider; } });
14
+ Object.defineProperty(exports, "resetProvider", { enumerable: true, get: function () { return ProviderFactory_1.resetProvider; } });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iDAAyE;AAAhE,8GAAA,aAAa,OAAA;AAAE,wHAAA,uBAAuB,OAAA;AAC/C,qDAK2B;AAJzB,kHAAA,eAAe,OAAA;AACf,qHAAA,kBAAkB,OAAA;AAClB,oHAAA,iBAAiB,OAAA;AACjB,gHAAA,aAAa,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-groq-provider",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Groq text generation provider for React Native applications",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./dist/index.d.ts",