@umituz/web-ai-groq-provider 1.1.8 → 1.1.10
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 umituz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-ai-groq-provider",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "Groq AI text generation provider for React web applications",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"typecheck": "tsc --noEmit",
|
|
16
|
-
"lint": "
|
|
16
|
+
"lint": "eslint .",
|
|
17
17
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean --external react",
|
|
18
18
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch --external react",
|
|
19
19
|
"version:patch": "npm version patch -m 'chore: release v%s'",
|
|
@@ -40,11 +40,14 @@
|
|
|
40
40
|
"react": ">=18.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
+
"@eslint/js": "^9.32.0",
|
|
43
44
|
"@types/node": "^20.0.0",
|
|
44
45
|
"@types/react": "^18.2.0",
|
|
46
|
+
"eslint": "^9.32.0",
|
|
45
47
|
"react": "18.3.1",
|
|
46
48
|
"tsup": "^8.0.0",
|
|
47
|
-
"typescript": "~5.9.2"
|
|
49
|
+
"typescript": "~5.9.2",
|
|
50
|
+
"typescript-eslint": "^8.38.0"
|
|
48
51
|
},
|
|
49
52
|
"publishConfig": {
|
|
50
53
|
"access": "public"
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import type {
|
|
7
7
|
IChatService,
|
|
8
|
-
IMessageFormatter,
|
|
9
8
|
} from "../interfaces";
|
|
10
9
|
import type {
|
|
11
10
|
ChatMessage,
|
|
@@ -30,7 +29,6 @@ class ChatService implements IChatService {
|
|
|
30
29
|
private config: ChatConfig = DEFAULT_CONFIG;
|
|
31
30
|
private systemPromptCache = new Map<string, string>();
|
|
32
31
|
private readonly PROMPT_CACHE_KEY_PREFIX = "system-prompt";
|
|
33
|
-
private readonly RESPONSE_CACHE_TTL = 300000; // 5 minutes
|
|
34
32
|
|
|
35
33
|
initialize(config: ChatConfig): void {
|
|
36
34
|
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
@@ -65,7 +63,7 @@ class ChatService implements IChatService {
|
|
|
65
63
|
};
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
async getConversation(
|
|
66
|
+
async getConversation(_conversationId: string): Promise<ChatConversation | null> {
|
|
69
67
|
// This would fetch from storage
|
|
70
68
|
// For now, return null - storage is handled by application
|
|
71
69
|
return null;
|
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
import type {
|
|
7
7
|
GroqMessage,
|
|
8
8
|
GroqChatResponse,
|
|
9
|
-
GroqChatChunk,
|
|
10
9
|
GroqChatRequest,
|
|
11
|
-
GroqConfig,
|
|
12
10
|
GroqGenerationConfig,
|
|
13
11
|
} from "../entities";
|
|
14
12
|
|
|
@@ -37,7 +35,7 @@ export interface StreamingCallbacks {
|
|
|
37
35
|
/**
|
|
38
36
|
* Structured text generation options
|
|
39
37
|
*/
|
|
40
|
-
export interface StructuredGenerationOptions
|
|
38
|
+
export interface StructuredGenerationOptions {
|
|
41
39
|
/** Model to use */
|
|
42
40
|
readonly model?: string;
|
|
43
41
|
/** Generation configuration */
|
|
@@ -55,7 +53,7 @@ export interface IGroqChatService {
|
|
|
55
53
|
/** Generate completion from messages */
|
|
56
54
|
generateChatCompletion(messages: GroqMessage[], options?: TextGenerationOptions): Promise<string>;
|
|
57
55
|
/** Generate structured JSON output */
|
|
58
|
-
generateStructured<T>(prompt: string, options?: StructuredGenerationOptions
|
|
56
|
+
generateStructured<T>(prompt: string, options?: StructuredGenerationOptions): Promise<T>;
|
|
59
57
|
/** Stream completion */
|
|
60
58
|
streamCompletion(
|
|
61
59
|
prompt: string,
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { IGroqHttpClient } from "../interfaces";
|
|
7
|
-
import type { GroqConfig, GroqChatRequest, GroqChatResponse
|
|
7
|
+
import type { GroqConfig, GroqChatRequest, GroqChatResponse } from "../entities";
|
|
8
8
|
import { GroqError } from "../utils/groq-error.util";
|
|
9
|
-
import { GroqErrorType, mapHttpStatusToErrorType
|
|
9
|
+
import { GroqErrorType, mapHttpStatusToErrorType } from "../constants/error.constants";
|
|
10
10
|
import { DEFAULT_BASE_URL, TIMEOUTS } from "../constants/groq.constants";
|
|
11
11
|
import { requestDeduplicator } from "../utils/request-deduplicator.util";
|
|
12
12
|
import { requestQueue } from "../utils/request-queue.util";
|
|
@@ -95,7 +95,7 @@ class TextGenerationService implements IGroqChatService {
|
|
|
95
95
|
|
|
96
96
|
async generateStructured<T>(
|
|
97
97
|
prompt: string,
|
|
98
|
-
options: StructuredGenerationOptions
|
|
98
|
+
options: StructuredGenerationOptions = {}
|
|
99
99
|
): Promise<T> {
|
|
100
100
|
const model = options.model || DEFAULT_MODELS.TEXT;
|
|
101
101
|
|