@umituz/react-native-ai-pruna-provider 1.0.43 → 1.0.45
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-pruna-provider",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.45",
|
|
4
4
|
"description": "Pruna AI provider for React Native - implements IAIProvider interface for unified AI generation",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -87,20 +87,26 @@ export class PrunaProvider implements IAIProvider {
|
|
|
87
87
|
const apiKey = this.validateInit();
|
|
88
88
|
const prunaModel = this.validateModel(model);
|
|
89
89
|
const sessionId = generationLogCollector.startSession();
|
|
90
|
-
generationLogCollector.log(sessionId, 'pruna-provider', `submitJob()
|
|
90
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `submitJob() START model: ${model}`);
|
|
91
91
|
try {
|
|
92
92
|
const submission = await queueOps.submitJob(prunaModel, input, apiKey, sessionId);
|
|
93
93
|
|
|
94
|
-
//
|
|
95
|
-
if (submission.statusUrl) {
|
|
96
|
-
storeRequestIdMapping(submission.requestId, submission.statusUrl, model);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Store requestId -> responseUrl mapping for immediate results (already complete)
|
|
94
|
+
// Log response type
|
|
100
95
|
if (submission.responseUrl) {
|
|
96
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `submitJob() IMMEDIATE RESULT - requestId: ${submission.requestId}, responseUrl: ${submission.responseUrl.substring(0, 80)}...`);
|
|
97
|
+
// Store requestId -> responseUrl mapping for immediate results (already complete)
|
|
101
98
|
storeImmediateResultMapping(submission.requestId, submission.responseUrl, model);
|
|
99
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `submitJob() Stored immediate result mapping: ${submission.requestId}`);
|
|
100
|
+
} else if (submission.statusUrl) {
|
|
101
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `submitJob() ASYNC JOB - requestId: ${submission.requestId}, statusUrl: ${submission.statusUrl.substring(0, 80)}...`);
|
|
102
|
+
// Store requestId -> statusUrl mapping for async jobs (requires polling)
|
|
103
|
+
storeRequestIdMapping(submission.requestId, submission.statusUrl, model);
|
|
104
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `submitJob() Stored async job mapping: ${submission.requestId}`);
|
|
105
|
+
} else {
|
|
106
|
+
generationLogCollector.warn(sessionId, 'pruna-provider', `submitJob() WARNING - No responseUrl or statusUrl in submission`);
|
|
102
107
|
}
|
|
103
108
|
|
|
109
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `submitJob() COMPLETE - returning submission with requestId: ${submission.requestId}`);
|
|
104
110
|
return submission;
|
|
105
111
|
} finally {
|
|
106
112
|
generationLogCollector.endSession(sessionId);
|
|
@@ -110,46 +116,82 @@ export class PrunaProvider implements IAIProvider {
|
|
|
110
116
|
async getJobStatus(model: string, requestId: string): Promise<JobStatus> {
|
|
111
117
|
const apiKey = this.validateInit();
|
|
112
118
|
const prunaModel = this.validateModel(model);
|
|
119
|
+
const sessionId = generationLogCollector.startSession();
|
|
120
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `getJobStatus() START - model: ${model}, requestId: ${requestId}`);
|
|
113
121
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
try {
|
|
123
|
+
// Check if this is an immediate result (already completed)
|
|
124
|
+
const responseUrl = getResponseUrlForRequestId(requestId);
|
|
125
|
+
if (responseUrl) {
|
|
126
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `getJobStatus() FOUND immediate result for ${requestId} - returning COMPLETED`);
|
|
127
|
+
generationLogCollector.endSession(sessionId);
|
|
128
|
+
// Result is already available
|
|
129
|
+
return {
|
|
130
|
+
status: "COMPLETED",
|
|
131
|
+
requestId,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
123
134
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
// Look up statusUrl from requestId mapping (async job)
|
|
136
|
+
const statusUrl = getStatusUrlForRequestId(requestId);
|
|
137
|
+
if (statusUrl) {
|
|
138
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `getJobStatus() FOUND async job for ${requestId} - polling statusUrl: ${statusUrl.substring(0, 80)}...`);
|
|
139
|
+
const result = await queueOps.getJobStatus(prunaModel, statusUrl, apiKey);
|
|
140
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `getJobStatus() Poll result: ${result.status}`);
|
|
141
|
+
generationLogCollector.endSession(sessionId);
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
129
144
|
|
|
130
|
-
|
|
131
|
-
|
|
145
|
+
// Fallback: assume requestId is actually a statusUrl (for direct calls with statusUrl)
|
|
146
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `getJobStatus() NO mapping found - treating ${requestId} as statusUrl directly`);
|
|
147
|
+
const result = await queueOps.getJobStatus(prunaModel, requestId, apiKey);
|
|
148
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `getJobStatus() Direct poll result: ${result.status}`);
|
|
149
|
+
generationLogCollector.endSession(sessionId);
|
|
150
|
+
return result;
|
|
151
|
+
} catch (error) {
|
|
152
|
+
generationLogCollector.error(sessionId, 'pruna-provider', `getJobStatus() ERROR: ${error instanceof Error ? error.message : String(error)}`);
|
|
153
|
+
generationLogCollector.endSession(sessionId);
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
132
156
|
}
|
|
133
157
|
|
|
134
158
|
async getJobResult<T = unknown>(model: string, requestId: string): Promise<T> {
|
|
135
159
|
const apiKey = this.validateInit();
|
|
136
160
|
const prunaModel = this.validateModel(model);
|
|
161
|
+
const sessionId = generationLogCollector.startSession();
|
|
162
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `getJobResult() START - model: ${model}, requestId: ${requestId}`);
|
|
137
163
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
164
|
+
try {
|
|
165
|
+
// Check if this is an immediate result (already completed)
|
|
166
|
+
const responseUrl = getResponseUrlForRequestId(requestId);
|
|
167
|
+
if (responseUrl) {
|
|
168
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `getJobResult() FOUND immediate result for ${requestId} - returning output: ${responseUrl.substring(0, 80)}...`);
|
|
169
|
+
generationLogCollector.endSession(sessionId);
|
|
170
|
+
// Return the immediate result in expected format for extractResultUrl
|
|
171
|
+
return { output: responseUrl } as T;
|
|
172
|
+
}
|
|
144
173
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
174
|
+
// Look up statusUrl from requestId mapping (async job)
|
|
175
|
+
const statusUrl = getStatusUrlForRequestId(requestId);
|
|
176
|
+
if (statusUrl) {
|
|
177
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `getJobResult() FOUND async job for ${requestId} - fetching from statusUrl: ${statusUrl.substring(0, 80)}...`);
|
|
178
|
+
const result = await queueOps.getJobResult<T>(prunaModel, statusUrl, apiKey);
|
|
179
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `getJobResult() Fetch complete`);
|
|
180
|
+
generationLogCollector.endSession(sessionId);
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
150
183
|
|
|
151
|
-
|
|
152
|
-
|
|
184
|
+
// Fallback: assume requestId is actually a statusUrl (for direct calls with statusUrl)
|
|
185
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `getJobResult() NO mapping found - treating ${requestId} as statusUrl directly`);
|
|
186
|
+
const result = await queueOps.getJobResult<T>(prunaModel, requestId, apiKey);
|
|
187
|
+
generationLogCollector.log(sessionId, 'pruna-provider', `getJobResult() Direct fetch complete`);
|
|
188
|
+
generationLogCollector.endSession(sessionId);
|
|
189
|
+
return result;
|
|
190
|
+
} catch (error) {
|
|
191
|
+
generationLogCollector.error(sessionId, 'pruna-provider', `getJobResult() ERROR: ${error instanceof Error ? error.message : String(error)}`);
|
|
192
|
+
generationLogCollector.endSession(sessionId);
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
153
195
|
}
|
|
154
196
|
|
|
155
197
|
async subscribe<T = unknown>(
|