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

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 (96) 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 +258 -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 +204 -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 +127 -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
  94. package/src/infrastructure/services/GroqClient.ts +61 -1
  95. package/src/infrastructure/services/StructuredText.ts +94 -1
  96. package/src/infrastructure/services/TextGeneration.ts +70 -0
@@ -25,8 +25,18 @@ export async function textGeneration(
25
25
  prompt: string,
26
26
  options: TextGenerationOptions = {}
27
27
  ): Promise<string> {
28
+ const startTime = Date.now();
28
29
  const model = options.model || DEFAULT_MODELS.TEXT;
29
30
 
31
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
32
+ console.log("[Groq] textGeneration called:", {
33
+ model,
34
+ promptLength: prompt.length,
35
+ promptPreview: prompt.substring(0, 100) + "...",
36
+ options: options.generationConfig,
37
+ });
38
+ }
39
+
30
40
  const messages: GroqMessage[] = [
31
41
  {
32
42
  role: "user",
@@ -46,7 +56,31 @@ export async function textGeneration(
46
56
  presence_penalty: options.generationConfig?.presencePenalty,
47
57
  };
48
58
 
59
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
60
+ console.log("[Groq] Sending request to API:", {
61
+ endpoint: "/v1/chat/completions",
62
+ requestBody: {
63
+ model: request.model,
64
+ messageCount: request.messages.length,
65
+ temperature: request.temperature,
66
+ max_tokens: request.max_tokens,
67
+ },
68
+ });
69
+ }
70
+
71
+ const apiStartTime = Date.now();
49
72
  const response = await groqHttpClient.chatCompletion(request);
73
+ const apiDuration = Date.now() - apiStartTime;
74
+
75
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
76
+ console.log("[Groq] API response received:", {
77
+ apiDuration: `${apiDuration}ms`,
78
+ hasChoices: !!response.choices?.length,
79
+ choiceCount: response.choices?.length || 0,
80
+ usage: response.usage,
81
+ finishReason: response.choices?.[0]?.finish_reason,
82
+ });
83
+ }
50
84
 
51
85
  const content = response.choices[0]?.message?.content;
52
86
  if (!content) {
@@ -56,6 +90,15 @@ export async function textGeneration(
56
90
  );
57
91
  }
58
92
 
93
+ const totalDuration = Date.now() - startTime;
94
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
95
+ console.log("[Groq] textGeneration complete:", {
96
+ totalDuration: `${totalDuration}ms`,
97
+ responseLength: content.length,
98
+ responsePreview: content.substring(0, 200) + "...",
99
+ });
100
+ }
101
+
59
102
  return content;
60
103
  }
61
104
 
@@ -66,8 +109,17 @@ export async function chatGeneration(
66
109
  messages: GroqMessage[],
67
110
  options: TextGenerationOptions = {}
68
111
  ): Promise<string> {
112
+ const startTime = Date.now();
69
113
  const model = options.model || DEFAULT_MODELS.TEXT;
70
114
 
115
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
116
+ console.log("[Groq] chatGeneration called:", {
117
+ model,
118
+ messageCount: messages.length,
119
+ options: options.generationConfig,
120
+ });
121
+ }
122
+
71
123
  const request: GroqChatRequest = {
72
124
  model,
73
125
  messages,
@@ -80,7 +132,17 @@ export async function chatGeneration(
80
132
  presence_penalty: options.generationConfig?.presencePenalty,
81
133
  };
82
134
 
135
+ const apiStartTime = Date.now();
83
136
  const response = await groqHttpClient.chatCompletion(request);
137
+ const apiDuration = Date.now() - apiStartTime;
138
+
139
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
140
+ console.log("[Groq] chatGeneration API response:", {
141
+ apiDuration: `${apiDuration}ms`,
142
+ usage: response.usage,
143
+ finishReason: response.choices?.[0]?.finish_reason,
144
+ });
145
+ }
84
146
 
85
147
  const content = response.choices[0]?.message?.content;
86
148
  if (!content) {
@@ -90,5 +152,13 @@ export async function chatGeneration(
90
152
  );
91
153
  }
92
154
 
155
+ const totalDuration = Date.now() - startTime;
156
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
157
+ console.log("[Groq] chatGeneration complete:", {
158
+ totalDuration: `${totalDuration}ms`,
159
+ responseLength: content.length,
160
+ });
161
+ }
162
+
93
163
  return content;
94
164
  }