@umituz/react-native-ai-groq-provider 1.0.28 → 1.0.29
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/application/use-cases/chat-generation.usecase.d.ts +11 -0
- package/dist/application/use-cases/chat-generation.usecase.d.ts.map +1 -0
- package/dist/application/use-cases/chat-generation.usecase.js +40 -0
- package/dist/application/use-cases/chat-generation.usecase.js.map +1 -0
- package/dist/application/use-cases/chat-session.usecase.d.ts +41 -0
- package/dist/application/use-cases/chat-session.usecase.d.ts.map +1 -0
- package/dist/application/use-cases/chat-session.usecase.js +138 -0
- package/dist/application/use-cases/chat-session.usecase.js.map +1 -0
- package/dist/application/use-cases/streaming.usecase.d.ts +17 -0
- package/dist/application/use-cases/streaming.usecase.d.ts.map +1 -0
- package/dist/application/use-cases/streaming.usecase.js +46 -0
- package/dist/application/use-cases/streaming.usecase.js.map +1 -0
- package/dist/application/use-cases/structured-generation.usecase.d.ts +14 -0
- package/dist/application/use-cases/structured-generation.usecase.d.ts.map +1 -0
- package/dist/application/use-cases/structured-generation.usecase.js +77 -0
- package/dist/application/use-cases/structured-generation.usecase.js.map +1 -0
- package/dist/application/use-cases/text-generation.usecase.d.ts +11 -0
- package/dist/application/use-cases/text-generation.usecase.d.ts.map +1 -0
- package/dist/application/use-cases/text-generation.usecase.js +36 -0
- package/dist/application/use-cases/text-generation.usecase.js.map +1 -0
- package/dist/domain/entities/error.types.d.ts +3 -1
- package/dist/domain/entities/error.types.d.ts.map +1 -1
- package/dist/domain/entities/error.types.js +12 -2
- package/dist/domain/entities/error.types.js.map +1 -1
- package/dist/index.d.ts +20 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -39
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/http/groq-http-client.d.ts +22 -0
- package/dist/infrastructure/http/groq-http-client.d.ts.map +1 -0
- package/dist/infrastructure/http/groq-http-client.js +166 -0
- package/dist/infrastructure/http/groq-http-client.js.map +1 -0
- package/dist/infrastructure/http/streaming-client.d.ts +12 -0
- package/dist/infrastructure/http/streaming-client.d.ts.map +1 -0
- package/dist/infrastructure/http/streaming-client.js +148 -0
- package/dist/infrastructure/http/streaming-client.js.map +1 -0
- package/dist/infrastructure/telemetry/TelemetryHooks.d.ts +16 -4
- package/dist/infrastructure/telemetry/TelemetryHooks.d.ts.map +1 -1
- package/dist/infrastructure/telemetry/TelemetryHooks.js +44 -11
- package/dist/infrastructure/telemetry/TelemetryHooks.js.map +1 -1
- package/dist/infrastructure/utils/async/execute-state.util.d.ts +6 -2
- package/dist/infrastructure/utils/async/execute-state.util.d.ts.map +1 -1
- package/dist/infrastructure/utils/async/execute-state.util.js +29 -4
- package/dist/infrastructure/utils/async/execute-state.util.js.map +1 -1
- package/dist/infrastructure/utils/calculation.util.d.ts +61 -0
- package/dist/infrastructure/utils/calculation.util.d.ts.map +1 -0
- package/dist/infrastructure/utils/calculation.util.js +165 -0
- package/dist/infrastructure/utils/calculation.util.js.map +1 -0
- package/dist/infrastructure/utils/content-mapper.util.d.ts +5 -1
- package/dist/infrastructure/utils/content-mapper.util.d.ts.map +1 -1
- package/dist/infrastructure/utils/content-mapper.util.js +17 -0
- package/dist/infrastructure/utils/content-mapper.util.js.map +1 -1
- package/dist/presentation/hooks/use-groq.hook.d.ts +26 -0
- package/dist/presentation/hooks/use-groq.hook.d.ts.map +1 -0
- package/dist/presentation/hooks/use-groq.hook.js +151 -0
- package/dist/presentation/hooks/use-groq.hook.js.map +1 -0
- package/dist/providers/ConfigBuilder.d.ts +1 -57
- package/dist/providers/ConfigBuilder.d.ts.map +1 -1
- package/dist/providers/ConfigBuilder.js +2 -68
- package/dist/providers/ConfigBuilder.js.map +1 -1
- package/dist/providers/ProviderFactory.d.ts +4 -34
- package/dist/providers/ProviderFactory.d.ts.map +1 -1
- package/dist/providers/ProviderFactory.js +9 -50
- package/dist/providers/ProviderFactory.js.map +1 -1
- package/dist/shared/logger.d.ts +26 -0
- package/dist/shared/logger.d.ts.map +1 -0
- package/dist/shared/logger.js +52 -0
- package/dist/shared/logger.js.map +1 -0
- package/dist/shared/request-builder.d.ts +17 -0
- package/dist/shared/request-builder.d.ts.map +1 -0
- package/dist/shared/request-builder.js +54 -0
- package/dist/shared/request-builder.js.map +1 -0
- package/dist/shared/response-handler.d.ts +38 -0
- package/dist/shared/response-handler.d.ts.map +1 -0
- package/dist/shared/response-handler.js +69 -0
- package/dist/shared/response-handler.js.map +1 -0
- package/dist/shared/timer.d.ts +20 -0
- package/dist/shared/timer.d.ts.map +1 -0
- package/dist/shared/timer.js +32 -0
- package/dist/shared/timer.js.map +1 -0
- package/package.json +1 -1
- package/src/application/use-cases/chat-generation.usecase.ts +55 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* useGroq Hook
|
|
4
|
+
* Main React hook for Groq text generation
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.useGroq = useGroq;
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const text_generation_usecase_1 = require("../../application/use-cases/text-generation.usecase");
|
|
10
|
+
const structured_generation_usecase_1 = require("../../application/use-cases/structured-generation.usecase");
|
|
11
|
+
const streaming_usecase_1 = require("../../application/use-cases/streaming.usecase");
|
|
12
|
+
const error_mapper_util_1 = require("../../infrastructure/utils/error-mapper.util");
|
|
13
|
+
function useGroq(options = {}) {
|
|
14
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
15
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
16
|
+
const [result, setResult] = (0, react_1.useState)(null);
|
|
17
|
+
// Use refs to avoid unnecessary re-creates and JSON.stringify
|
|
18
|
+
const optionsRef = (0, react_1.useRef)(options);
|
|
19
|
+
const callbacksRef = (0, react_1.useRef)({
|
|
20
|
+
onStart: options.onStart,
|
|
21
|
+
onSuccess: options.onSuccess,
|
|
22
|
+
onError: options.onError,
|
|
23
|
+
});
|
|
24
|
+
// Update refs when options change
|
|
25
|
+
if (options.model !== optionsRef.current.model) {
|
|
26
|
+
optionsRef.current.model = options.model;
|
|
27
|
+
}
|
|
28
|
+
if (options.generationConfig !== optionsRef.current.generationConfig) {
|
|
29
|
+
optionsRef.current.generationConfig = options.generationConfig;
|
|
30
|
+
}
|
|
31
|
+
if (options.onStart !== callbacksRef.current.onStart) {
|
|
32
|
+
callbacksRef.current.onStart = options.onStart;
|
|
33
|
+
}
|
|
34
|
+
if (options.onSuccess !== callbacksRef.current.onSuccess) {
|
|
35
|
+
callbacksRef.current.onSuccess = options.onSuccess;
|
|
36
|
+
}
|
|
37
|
+
if (options.onError !== callbacksRef.current.onError) {
|
|
38
|
+
callbacksRef.current.onError = options.onError;
|
|
39
|
+
}
|
|
40
|
+
const generate = (0, react_1.useCallback)(async (prompt, config) => {
|
|
41
|
+
setIsLoading(true);
|
|
42
|
+
setError(null);
|
|
43
|
+
setResult(null);
|
|
44
|
+
callbacksRef.current.onStart?.();
|
|
45
|
+
try {
|
|
46
|
+
const response = await (0, text_generation_usecase_1.generateText)(prompt, {
|
|
47
|
+
model: optionsRef.current.model,
|
|
48
|
+
generationConfig: {
|
|
49
|
+
...optionsRef.current.generationConfig,
|
|
50
|
+
...config,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
setResult(response);
|
|
54
|
+
callbacksRef.current.onSuccess?.(response);
|
|
55
|
+
return response;
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
const errorMessage = (0, error_mapper_util_1.getUserFriendlyError)(err);
|
|
59
|
+
setError(errorMessage);
|
|
60
|
+
callbacksRef.current.onError?.(errorMessage);
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
setIsLoading(false);
|
|
65
|
+
}
|
|
66
|
+
}, [] // No deps - uses refs
|
|
67
|
+
);
|
|
68
|
+
const generateJSON = (0, react_1.useCallback)(async (prompt, config) => {
|
|
69
|
+
setIsLoading(true);
|
|
70
|
+
setError(null);
|
|
71
|
+
setResult(null);
|
|
72
|
+
callbacksRef.current.onStart?.();
|
|
73
|
+
try {
|
|
74
|
+
const response = await (0, structured_generation_usecase_1.generateStructured)(prompt, {
|
|
75
|
+
model: optionsRef.current.model,
|
|
76
|
+
generationConfig: {
|
|
77
|
+
...optionsRef.current.generationConfig,
|
|
78
|
+
...config,
|
|
79
|
+
},
|
|
80
|
+
schema: config?.schema,
|
|
81
|
+
});
|
|
82
|
+
const jsonStr = JSON.stringify(response, null, 2);
|
|
83
|
+
setResult(jsonStr);
|
|
84
|
+
callbacksRef.current.onSuccess?.(jsonStr);
|
|
85
|
+
return response;
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
const errorMessage = (0, error_mapper_util_1.getUserFriendlyError)(err);
|
|
89
|
+
setError(errorMessage);
|
|
90
|
+
callbacksRef.current.onError?.(errorMessage);
|
|
91
|
+
throw err;
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
setIsLoading(false);
|
|
95
|
+
}
|
|
96
|
+
}, [] // No deps - uses refs
|
|
97
|
+
);
|
|
98
|
+
const stream = (0, react_1.useCallback)(async (prompt, onChunk, config) => {
|
|
99
|
+
setIsLoading(true);
|
|
100
|
+
setError(null);
|
|
101
|
+
setResult(null);
|
|
102
|
+
let fullContent = "";
|
|
103
|
+
callbacksRef.current.onStart?.();
|
|
104
|
+
try {
|
|
105
|
+
for await (const chunk of (0, streaming_usecase_1.streamText)(prompt, {
|
|
106
|
+
model: optionsRef.current.model,
|
|
107
|
+
generationConfig: {
|
|
108
|
+
...optionsRef.current.generationConfig,
|
|
109
|
+
...config,
|
|
110
|
+
},
|
|
111
|
+
callbacks: { onChunk: (c) => {
|
|
112
|
+
fullContent += c;
|
|
113
|
+
onChunk(c);
|
|
114
|
+
} },
|
|
115
|
+
})) {
|
|
116
|
+
fullContent += chunk;
|
|
117
|
+
}
|
|
118
|
+
setResult(fullContent);
|
|
119
|
+
callbacksRef.current.onSuccess?.(fullContent);
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
const errorMessage = (0, error_mapper_util_1.getUserFriendlyError)(err);
|
|
123
|
+
setError(errorMessage);
|
|
124
|
+
callbacksRef.current.onError?.(errorMessage);
|
|
125
|
+
throw err;
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
setIsLoading(false);
|
|
129
|
+
}
|
|
130
|
+
}, [] // No deps - uses refs
|
|
131
|
+
);
|
|
132
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
133
|
+
setIsLoading(false);
|
|
134
|
+
setError(null);
|
|
135
|
+
setResult(null);
|
|
136
|
+
}, []);
|
|
137
|
+
const clearError = (0, react_1.useCallback)(() => {
|
|
138
|
+
setError(null);
|
|
139
|
+
}, []);
|
|
140
|
+
return {
|
|
141
|
+
isLoading,
|
|
142
|
+
error,
|
|
143
|
+
result,
|
|
144
|
+
generate,
|
|
145
|
+
generateJSON,
|
|
146
|
+
stream,
|
|
147
|
+
reset,
|
|
148
|
+
clearError,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=use-groq.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-groq.hook.js","sourceRoot":"","sources":["../../../src/presentation/hooks/use-groq.hook.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAmCH,0BAkKC;AAnMD,iCAAsD;AAEtD,iGAAmF;AACnF,6GAA+F;AAC/F,qFAA2E;AAC3E,oFAAoF;AA4BpF,SAAgB,OAAO,CAAC,UAA0B,EAAE;IAClD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAgB,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,MAAM,EAAE,SAAS,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
4
|
*/
|
|
5
|
-
import type { GroqConfig, GroqGenerationConfig } from "../domain/entities";
|
|
5
|
+
import type { GroqConfig, GroqGenerationConfig } from "../domain/entities/groq.types";
|
|
6
6
|
/**
|
|
7
7
|
* Builder for Groq configuration
|
|
8
8
|
*/
|
|
9
9
|
export declare class ConfigBuilder {
|
|
10
10
|
private config;
|
|
11
|
-
/**
|
|
12
|
-
* Set API key
|
|
13
|
-
*/
|
|
14
11
|
withApiKey(apiKey: string): ConfigBuilder;
|
|
15
|
-
/**
|
|
16
|
-
* Set base URL
|
|
17
|
-
*/
|
|
18
12
|
withBaseUrl(baseUrl: string): ConfigBuilder;
|
|
19
|
-
/**
|
|
20
|
-
* Set timeout
|
|
21
|
-
*/
|
|
22
13
|
withTimeout(timeoutMs: number): ConfigBuilder;
|
|
23
|
-
/**
|
|
24
|
-
* Set default text model
|
|
25
|
-
*/
|
|
26
14
|
withTextModel(model: string): ConfigBuilder;
|
|
27
|
-
/**
|
|
28
|
-
* Build configuration
|
|
29
|
-
*/
|
|
30
15
|
build(): GroqConfig;
|
|
31
|
-
/**
|
|
32
|
-
* Create a new builder instance
|
|
33
|
-
*/
|
|
34
|
-
static create(): ConfigBuilder;
|
|
35
16
|
}
|
|
36
17
|
/**
|
|
37
18
|
* Builder for generation configuration
|
|
38
19
|
*/
|
|
39
20
|
export declare class GenerationConfigBuilder {
|
|
40
21
|
private config;
|
|
41
|
-
/**
|
|
42
|
-
* Set temperature
|
|
43
|
-
*/
|
|
44
22
|
withTemperature(temperature: number): GenerationConfigBuilder;
|
|
45
|
-
/**
|
|
46
|
-
* Set max tokens
|
|
47
|
-
*/
|
|
48
23
|
withMaxTokens(maxTokens: number): GenerationConfigBuilder;
|
|
49
|
-
/**
|
|
50
|
-
* Set top P
|
|
51
|
-
*/
|
|
52
24
|
withTopP(topP: number): GenerationConfigBuilder;
|
|
53
|
-
/**
|
|
54
|
-
* Set frequency penalty
|
|
55
|
-
*/
|
|
56
25
|
withFrequencyPenalty(penalty: number): GenerationConfigBuilder;
|
|
57
|
-
/**
|
|
58
|
-
* Set presence penalty
|
|
59
|
-
*/
|
|
60
26
|
withPresencePenalty(penalty: number): GenerationConfigBuilder;
|
|
61
|
-
/**
|
|
62
|
-
* Set stop sequences
|
|
63
|
-
*/
|
|
64
27
|
withStop(stop: string[]): GenerationConfigBuilder;
|
|
65
|
-
/**
|
|
66
|
-
* Build configuration
|
|
67
|
-
*/
|
|
68
28
|
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
29
|
}
|
|
86
30
|
//# sourceMappingURL=ConfigBuilder.d.ts.map
|
|
@@ -1 +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,
|
|
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,+BAA+B,CAAC;AAGtF;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAA2B;IAEzC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAKzC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa;IAK3C,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa;IAK7C,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa;IAK3C,KAAK,IAAI,UAAU;CAYpB;AAED;;GAEG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,MAAM,CAA4B;IAE1C,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,uBAAuB;IAK7D,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB;IAKzD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB;IAK/C,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB;IAK9D,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB;IAK7D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,uBAAuB;IAKjD,KAAK,IAAI,oBAAoB;CAG9B"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.GenerationConfigBuilder = exports.ConfigBuilder = void 0;
|
|
8
|
-
const
|
|
8
|
+
const groq_types_1 = require("../domain/entities/groq.types");
|
|
9
9
|
/**
|
|
10
10
|
* Builder for Groq configuration
|
|
11
11
|
*/
|
|
@@ -13,37 +13,22 @@ class ConfigBuilder {
|
|
|
13
13
|
constructor() {
|
|
14
14
|
this.config = {};
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Set API key
|
|
18
|
-
*/
|
|
19
16
|
withApiKey(apiKey) {
|
|
20
17
|
this.config.apiKey = apiKey;
|
|
21
18
|
return this;
|
|
22
19
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Set base URL
|
|
25
|
-
*/
|
|
26
20
|
withBaseUrl(baseUrl) {
|
|
27
21
|
this.config.baseUrl = baseUrl;
|
|
28
22
|
return this;
|
|
29
23
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Set timeout
|
|
32
|
-
*/
|
|
33
24
|
withTimeout(timeoutMs) {
|
|
34
25
|
this.config.timeoutMs = timeoutMs;
|
|
35
26
|
return this;
|
|
36
27
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Set default text model
|
|
39
|
-
*/
|
|
40
28
|
withTextModel(model) {
|
|
41
29
|
this.config.textModel = model;
|
|
42
30
|
return this;
|
|
43
31
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Build configuration
|
|
46
|
-
*/
|
|
47
32
|
build() {
|
|
48
33
|
if (!this.config.apiKey) {
|
|
49
34
|
throw new Error("API key is required. Use withApiKey() to set it.");
|
|
@@ -52,15 +37,9 @@ class ConfigBuilder {
|
|
|
52
37
|
apiKey: this.config.apiKey,
|
|
53
38
|
baseUrl: this.config.baseUrl,
|
|
54
39
|
timeoutMs: this.config.timeoutMs,
|
|
55
|
-
textModel: this.config.textModel ||
|
|
40
|
+
textModel: this.config.textModel || groq_types_1.DEFAULT_MODELS.TEXT,
|
|
56
41
|
};
|
|
57
42
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Create a new builder instance
|
|
60
|
-
*/
|
|
61
|
-
static create() {
|
|
62
|
-
return new ConfigBuilder();
|
|
63
|
-
}
|
|
64
43
|
}
|
|
65
44
|
exports.ConfigBuilder = ConfigBuilder;
|
|
66
45
|
/**
|
|
@@ -70,78 +49,33 @@ class GenerationConfigBuilder {
|
|
|
70
49
|
constructor() {
|
|
71
50
|
this.config = {};
|
|
72
51
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Set temperature
|
|
75
|
-
*/
|
|
76
52
|
withTemperature(temperature) {
|
|
77
53
|
this.config.temperature = temperature;
|
|
78
54
|
return this;
|
|
79
55
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Set max tokens
|
|
82
|
-
*/
|
|
83
56
|
withMaxTokens(maxTokens) {
|
|
84
57
|
this.config.maxTokens = maxTokens;
|
|
85
58
|
return this;
|
|
86
59
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Set top P
|
|
89
|
-
*/
|
|
90
60
|
withTopP(topP) {
|
|
91
61
|
this.config.topP = topP;
|
|
92
62
|
return this;
|
|
93
63
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Set frequency penalty
|
|
96
|
-
*/
|
|
97
64
|
withFrequencyPenalty(penalty) {
|
|
98
65
|
this.config.frequencyPenalty = penalty;
|
|
99
66
|
return this;
|
|
100
67
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Set presence penalty
|
|
103
|
-
*/
|
|
104
68
|
withPresencePenalty(penalty) {
|
|
105
69
|
this.config.presencePenalty = penalty;
|
|
106
70
|
return this;
|
|
107
71
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Set stop sequences
|
|
110
|
-
*/
|
|
111
72
|
withStop(stop) {
|
|
112
73
|
this.config.stop = stop;
|
|
113
74
|
return this;
|
|
114
75
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Build configuration
|
|
117
|
-
*/
|
|
118
76
|
build() {
|
|
119
77
|
return { ...this.config };
|
|
120
78
|
}
|
|
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
79
|
}
|
|
146
80
|
exports.GenerationConfigBuilder = GenerationConfigBuilder;
|
|
147
81
|
//# sourceMappingURL=ConfigBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigBuilder.js","sourceRoot":"","sources":["../../src/providers/ConfigBuilder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,
|
|
1
|
+
{"version":3,"file":"ConfigBuilder.js","sourceRoot":"","sources":["../../src/providers/ConfigBuilder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,8DAA+D;AAE/D;;GAEG;AACH,MAAa,aAAa;IAA1B;QACU,WAAM,GAAwB,EAAE,CAAC;IAkC3C,CAAC;IAhCC,UAAU,CAAC,MAAc;QACvB,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,OAAe;QACzB,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,SAAiB;QAC3B,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,KAAa;QACzB,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtE,CAAC;QAED,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;YAC1B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,2BAAc,CAAC,IAAI;SACxD,CAAC;IACJ,CAAC;CACF;AAnCD,sCAmCC;AAED;;GAEG;AACH,MAAa,uBAAuB;IAApC;QACU,WAAM,GAAyB,EAAE,CAAC;IAmC5C,CAAC;IAjCC,eAAe,CAAC,WAAmB;QACjC,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,SAAiB;QAC7B,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oBAAoB,CAAC,OAAe;QAClC,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,OAAO,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mBAAmB,CAAC,OAAe;QACjC,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,OAAO,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,IAAc;QACrB,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF;AApCD,0DAoCC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Provider Factory
|
|
3
3
|
* Factory for creating configured Groq provider instances
|
|
4
4
|
*/
|
|
5
|
-
import { ConfigBuilder, GenerationConfigBuilder } from "./ConfigBuilder";
|
|
6
5
|
/**
|
|
7
6
|
* Provider configuration options
|
|
8
7
|
*/
|
|
@@ -12,45 +11,16 @@ export interface ProviderConfig {
|
|
|
12
11
|
timeoutMs?: number;
|
|
13
12
|
defaultModel?: string;
|
|
14
13
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Provider factory options
|
|
17
|
-
*/
|
|
18
|
-
export interface ProviderFactoryOptions {
|
|
19
|
-
enableTelemetry?: boolean;
|
|
20
|
-
onError?: (error: Error) => void;
|
|
21
|
-
}
|
|
22
14
|
/**
|
|
23
15
|
* Initialize Groq provider with configuration
|
|
24
16
|
*/
|
|
25
17
|
export declare function initializeProvider(config: ProviderConfig): void;
|
|
26
18
|
/**
|
|
27
|
-
*
|
|
19
|
+
* Reset provider configuration
|
|
28
20
|
*/
|
|
29
|
-
export declare
|
|
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;
|
|
21
|
+
export declare function resetProvider(): void;
|
|
51
22
|
/**
|
|
52
|
-
*
|
|
23
|
+
* Check if provider is initialized
|
|
53
24
|
*/
|
|
54
|
-
export declare function
|
|
55
|
-
export { ConfigBuilder, GenerationConfigBuilder };
|
|
25
|
+
export declare function isProviderInitialized(): boolean;
|
|
56
26
|
//# sourceMappingURL=ProviderFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProviderFactory.d.ts","sourceRoot":"","sources":["../../src/providers/ProviderFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH
|
|
1
|
+
{"version":3,"file":"ProviderFactory.d.ts","sourceRoot":"","sources":["../../src/providers/ProviderFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;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,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAO/D;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C"}
|
|
@@ -4,19 +4,15 @@
|
|
|
4
4
|
* Factory for creating configured Groq provider instances
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.GenerationConfigBuilder = exports.ConfigBuilder = exports.providerFactory = void 0;
|
|
8
7
|
exports.initializeProvider = initializeProvider;
|
|
9
|
-
exports.configureProvider = configureProvider;
|
|
10
8
|
exports.resetProvider = resetProvider;
|
|
11
|
-
|
|
12
|
-
const
|
|
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; } });
|
|
9
|
+
exports.isProviderInitialized = isProviderInitialized;
|
|
10
|
+
const groq_http_client_1 = require("../infrastructure/http/groq-http-client");
|
|
15
11
|
/**
|
|
16
12
|
* Initialize Groq provider with configuration
|
|
17
13
|
*/
|
|
18
14
|
function initializeProvider(config) {
|
|
19
|
-
|
|
15
|
+
groq_http_client_1.groqHttpClient.initialize({
|
|
20
16
|
apiKey: config.apiKey,
|
|
21
17
|
baseUrl: config.baseUrl,
|
|
22
18
|
timeoutMs: config.timeoutMs,
|
|
@@ -24,52 +20,15 @@ function initializeProvider(config) {
|
|
|
24
20
|
});
|
|
25
21
|
}
|
|
26
22
|
/**
|
|
27
|
-
*
|
|
23
|
+
* Reset provider configuration
|
|
28
24
|
*/
|
|
29
|
-
|
|
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);
|
|
25
|
+
function resetProvider() {
|
|
26
|
+
groq_http_client_1.groqHttpClient.reset();
|
|
68
27
|
}
|
|
69
28
|
/**
|
|
70
|
-
*
|
|
29
|
+
* Check if provider is initialized
|
|
71
30
|
*/
|
|
72
|
-
function
|
|
73
|
-
|
|
31
|
+
function isProviderInitialized() {
|
|
32
|
+
return groq_http_client_1.groqHttpClient.isInitialized();
|
|
74
33
|
}
|
|
75
34
|
//# sourceMappingURL=ProviderFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProviderFactory.js","sourceRoot":"","sources":["../../src/providers/ProviderFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"ProviderFactory.js","sourceRoot":"","sources":["../../src/providers/ProviderFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAiBH,gDAOC;AAKD,sCAEC;AAKD,sDAEC;AApCD,8EAAyE;AAYzE;;GAEG;AACH,SAAgB,kBAAkB,CAAC,MAAsB;IACvD,iCAAc,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;AACH,SAAgB,aAAa;IAC3B,iCAAc,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB;IACnC,OAAO,iCAAc,CAAC,aAAa,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger Utility
|
|
3
|
+
* Centralized logging for the entire application
|
|
4
|
+
*/
|
|
5
|
+
export declare enum LogLevel {
|
|
6
|
+
DEBUG = "DEBUG",
|
|
7
|
+
INFO = "INFO",
|
|
8
|
+
WARN = "WARN",
|
|
9
|
+
ERROR = "ERROR"
|
|
10
|
+
}
|
|
11
|
+
export interface LogContext {
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
declare class Logger {
|
|
15
|
+
private enabled;
|
|
16
|
+
constructor();
|
|
17
|
+
private log;
|
|
18
|
+
debug(tag: string, message: string, context?: LogContext): void;
|
|
19
|
+
info(tag: string, message: string, context?: LogContext): void;
|
|
20
|
+
warn(tag: string, message: string, context?: LogContext): void;
|
|
21
|
+
error(tag: string, message: string, context?: LogContext): void;
|
|
22
|
+
isEnabled(): boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const logger: Logger;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/shared/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oBAAY,QAAQ;IAClB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,cAAM,MAAM;IACV,OAAO,CAAC,OAAO,CAAU;;IAMzB,OAAO,CAAC,GAAG;IAkBX,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IAI/D,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IAI9D,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IAI9D,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IAI/D,SAAS,IAAI,OAAO;CAGrB;AAED,eAAO,MAAM,MAAM,QAAe,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Logger Utility
|
|
4
|
+
* Centralized logging for the entire application
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.logger = exports.LogLevel = void 0;
|
|
8
|
+
var LogLevel;
|
|
9
|
+
(function (LogLevel) {
|
|
10
|
+
LogLevel["DEBUG"] = "DEBUG";
|
|
11
|
+
LogLevel["INFO"] = "INFO";
|
|
12
|
+
LogLevel["WARN"] = "WARN";
|
|
13
|
+
LogLevel["ERROR"] = "ERROR";
|
|
14
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
15
|
+
class Logger {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.enabled = typeof __DEV__ !== "undefined" && __DEV__;
|
|
18
|
+
}
|
|
19
|
+
log(level, tag, message, context) {
|
|
20
|
+
if (!this.enabled)
|
|
21
|
+
return;
|
|
22
|
+
const timestamp = new Date().toISOString();
|
|
23
|
+
const logMessage = `[${timestamp}] [${level}] [${tag}] ${message}`;
|
|
24
|
+
switch (level) {
|
|
25
|
+
case LogLevel.ERROR:
|
|
26
|
+
console.error(logMessage, context || "");
|
|
27
|
+
break;
|
|
28
|
+
case LogLevel.WARN:
|
|
29
|
+
console.warn(logMessage, context || "");
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
console.log(logMessage, context || "");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
debug(tag, message, context) {
|
|
36
|
+
this.log(LogLevel.DEBUG, tag, message, context);
|
|
37
|
+
}
|
|
38
|
+
info(tag, message, context) {
|
|
39
|
+
this.log(LogLevel.INFO, tag, message, context);
|
|
40
|
+
}
|
|
41
|
+
warn(tag, message, context) {
|
|
42
|
+
this.log(LogLevel.WARN, tag, message, context);
|
|
43
|
+
}
|
|
44
|
+
error(tag, message, context) {
|
|
45
|
+
this.log(LogLevel.ERROR, tag, message, context);
|
|
46
|
+
}
|
|
47
|
+
isEnabled() {
|
|
48
|
+
return this.enabled;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.logger = new Logger();
|
|
52
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/shared/logger.ts"],"names":[],"mappings":";AA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I,CAAC,GAAW,EAAE,OAAe,EAAE,OAAoB;QACrD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,OAAe,EAAE,OAAoB;QACtD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAEY,QAAA,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request Builder Utility
|
|
3
|
+
* Centralized request building logic
|
|
4
|
+
*/
|
|
5
|
+
import type { GroqChatRequest, GroqGenerationConfig, GroqMessage } from "../domain/entities/groq.types";
|
|
6
|
+
export interface RequestBuilderOptions {
|
|
7
|
+
model?: string;
|
|
8
|
+
generationConfig?: GroqGenerationConfig;
|
|
9
|
+
defaultTemperature?: number;
|
|
10
|
+
defaultMaxTokens?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class RequestBuilder {
|
|
13
|
+
static buildChatRequest(messages: GroqMessage[], options?: RequestBuilderOptions): GroqChatRequest;
|
|
14
|
+
static buildPromptRequest(prompt: string, options?: RequestBuilderOptions): GroqChatRequest;
|
|
15
|
+
static buildSystemPromptRequest(systemPrompt: string, userPrompt: string, options?: RequestBuilderOptions): GroqChatRequest;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=request-builder.d.ts.map
|