@umituz/react-native-ai-generation-content 1.12.5 → 1.12.7
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-generation-content",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.7",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -40,14 +40,12 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@react-navigation/native": ">=6.0.0",
|
|
42
42
|
"@tanstack/react-query": ">=5.0.0",
|
|
43
|
-
"@umituz/react-native-ai-gemini-provider": "latest",
|
|
44
43
|
"@umituz/react-native-alert": "latest",
|
|
45
44
|
"@umituz/react-native-animation": "latest",
|
|
46
45
|
"@umituz/react-native-bottom-sheet": "latest",
|
|
47
46
|
"@umituz/react-native-design-system": "latest",
|
|
48
47
|
"@umituz/react-native-firebase": "latest",
|
|
49
48
|
"@umituz/react-native-image": "latest",
|
|
50
|
-
"@umituz/react-native-localization": "latest",
|
|
51
49
|
"@umituz/react-native-offline": "latest",
|
|
52
50
|
"@umituz/react-native-uuid": "latest",
|
|
53
51
|
"expo-linear-gradient": ">=15.0.0",
|
|
@@ -64,14 +62,12 @@
|
|
|
64
62
|
"@types/react-native": "^0.73.0",
|
|
65
63
|
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
66
64
|
"@typescript-eslint/parser": "^7.0.0",
|
|
67
|
-
"@umituz/react-native-ai-gemini-provider": "latest",
|
|
68
65
|
"@umituz/react-native-alert": "latest",
|
|
69
66
|
"@umituz/react-native-animation": "latest",
|
|
70
67
|
"@umituz/react-native-bottom-sheet": "latest",
|
|
71
68
|
"@umituz/react-native-design-system": "latest",
|
|
72
69
|
"@umituz/react-native-firebase": "latest",
|
|
73
70
|
"@umituz/react-native-image": "latest",
|
|
74
|
-
"@umituz/react-native-localization": "latest",
|
|
75
71
|
"@umituz/react-native-offline": "latest",
|
|
76
72
|
"@umituz/react-native-uuid": "latest",
|
|
77
73
|
"eslint": "^8.57.0",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Face Analyzer
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Provider-agnostic face detection analyzer.
|
|
5
|
+
* Main app injects the AI provider function.
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
|
-
import { geminiProviderService } from "@umituz/react-native-ai-gemini-provider";
|
|
8
8
|
import type { FaceDetectionResult } from "../../domain/entities/FaceDetection";
|
|
9
9
|
import { FACE_DETECTION_PROMPTS } from "../../domain/constants/faceDetectionConstants";
|
|
10
10
|
import {
|
|
@@ -12,17 +12,21 @@ import {
|
|
|
12
12
|
createFailedResult,
|
|
13
13
|
} from "../validators/faceValidator";
|
|
14
14
|
|
|
15
|
+
export type AIAnalyzerFunction = (
|
|
16
|
+
model: string,
|
|
17
|
+
params: { prompt: string; image_url: string }
|
|
18
|
+
) => Promise<{ text: string }>;
|
|
19
|
+
|
|
15
20
|
export const analyzeImageForFace = async (
|
|
16
21
|
base64Image: string,
|
|
22
|
+
aiAnalyzer: AIAnalyzerFunction,
|
|
23
|
+
model: string
|
|
17
24
|
): Promise<FaceDetectionResult> => {
|
|
18
25
|
try {
|
|
19
|
-
const result = await
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
image_url: base64Image,
|
|
24
|
-
},
|
|
25
|
-
);
|
|
26
|
+
const result = await aiAnalyzer(model, {
|
|
27
|
+
prompt: FACE_DETECTION_PROMPTS.analyze,
|
|
28
|
+
image_url: base64Image,
|
|
29
|
+
});
|
|
26
30
|
|
|
27
31
|
if (!result.text) {
|
|
28
32
|
return createFailedResult("No response from AI");
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* FaceValidationStatus Component
|
|
3
3
|
*
|
|
4
4
|
* Displays face validation status with appropriate styling.
|
|
5
|
+
* Translations provided by main app via props.
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
import React from "react";
|
|
@@ -11,19 +12,26 @@ import {
|
|
|
11
12
|
AtomicIcon,
|
|
12
13
|
useAppDesignTokens,
|
|
13
14
|
} from "@umituz/react-native-design-system";
|
|
14
|
-
import { useLocalization } from "@umituz/react-native-localization";
|
|
15
15
|
import type { FaceValidationState } from "../../domain/entities/FaceDetection";
|
|
16
16
|
import { isValidFace } from "../../infrastructure/validators/faceValidator";
|
|
17
17
|
|
|
18
|
+
export interface FaceValidationLabels {
|
|
19
|
+
analyzing: string;
|
|
20
|
+
error: string;
|
|
21
|
+
success: string;
|
|
22
|
+
noFace: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
18
25
|
interface FaceValidationStatusProps {
|
|
19
26
|
state: FaceValidationState;
|
|
27
|
+
labels: FaceValidationLabels;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
export const FaceValidationStatus: React.FC<FaceValidationStatusProps> = ({
|
|
23
31
|
state,
|
|
32
|
+
labels,
|
|
24
33
|
}) => {
|
|
25
34
|
const tokens = useAppDesignTokens();
|
|
26
|
-
const { t } = useLocalization();
|
|
27
35
|
|
|
28
36
|
if (state.isValidating) {
|
|
29
37
|
return (
|
|
@@ -34,7 +42,7 @@ export const FaceValidationStatus: React.FC<FaceValidationStatusProps> = ({
|
|
|
34
42
|
<AtomicText
|
|
35
43
|
style={[styles.text, { color: tokens.colors.textSecondary }]}
|
|
36
44
|
>
|
|
37
|
-
{
|
|
45
|
+
{labels.analyzing}
|
|
38
46
|
</AtomicText>
|
|
39
47
|
</View>
|
|
40
48
|
);
|
|
@@ -50,11 +58,11 @@ export const FaceValidationStatus: React.FC<FaceValidationStatusProps> = ({
|
|
|
50
58
|
>
|
|
51
59
|
<AtomicIcon
|
|
52
60
|
name="alert-circle"
|
|
53
|
-
size=
|
|
61
|
+
size="sm"
|
|
54
62
|
customColor={tokens.colors.error}
|
|
55
63
|
/>
|
|
56
64
|
<AtomicText style={[styles.text, { color: tokens.colors.error }]}>
|
|
57
|
-
{
|
|
65
|
+
{labels.error}
|
|
58
66
|
</AtomicText>
|
|
59
67
|
</View>
|
|
60
68
|
);
|
|
@@ -79,7 +87,7 @@ export const FaceValidationStatus: React.FC<FaceValidationStatusProps> = ({
|
|
|
79
87
|
>
|
|
80
88
|
<AtomicIcon
|
|
81
89
|
name={valid ? "checkmark-circle" : "close-circle"}
|
|
82
|
-
size=
|
|
90
|
+
size="sm"
|
|
83
91
|
customColor={valid ? tokens.colors.success : tokens.colors.error}
|
|
84
92
|
/>
|
|
85
93
|
<AtomicText
|
|
@@ -88,7 +96,7 @@ export const FaceValidationStatus: React.FC<FaceValidationStatusProps> = ({
|
|
|
88
96
|
{ color: valid ? tokens.colors.success : tokens.colors.error },
|
|
89
97
|
]}
|
|
90
98
|
>
|
|
91
|
-
{valid ?
|
|
99
|
+
{valid ? labels.success : labels.noFace}
|
|
92
100
|
</AtomicText>
|
|
93
101
|
</View>
|
|
94
102
|
);
|
|
@@ -9,9 +9,14 @@ import type {
|
|
|
9
9
|
FaceValidationState,
|
|
10
10
|
FaceDetectionResult,
|
|
11
11
|
} from "../../domain/entities/FaceDetection";
|
|
12
|
-
import { analyzeImageForFace } from "../../infrastructure/analyzers/faceAnalyzer";
|
|
12
|
+
import { analyzeImageForFace, type AIAnalyzerFunction } from "../../infrastructure/analyzers/faceAnalyzer";
|
|
13
13
|
import { isValidFace } from "../../infrastructure/validators/faceValidator";
|
|
14
14
|
|
|
15
|
+
interface UseFaceDetectionProps {
|
|
16
|
+
aiAnalyzer: AIAnalyzerFunction;
|
|
17
|
+
model: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
interface UseFaceDetectionReturn {
|
|
16
21
|
state: FaceValidationState;
|
|
17
22
|
validateImage: (base64Image: string) => Promise<FaceDetectionResult>;
|
|
@@ -25,14 +30,14 @@ const initialState: FaceValidationState = {
|
|
|
25
30
|
error: null,
|
|
26
31
|
};
|
|
27
32
|
|
|
28
|
-
export const useFaceDetection = (): UseFaceDetectionReturn => {
|
|
33
|
+
export const useFaceDetection = ({ aiAnalyzer, model }: UseFaceDetectionProps): UseFaceDetectionReturn => {
|
|
29
34
|
const [state, setState] = useState<FaceValidationState>(initialState);
|
|
30
35
|
|
|
31
36
|
const validateImage = useCallback(async (base64Image: string) => {
|
|
32
37
|
setState({ isValidating: true, result: null, error: null });
|
|
33
38
|
|
|
34
39
|
try {
|
|
35
|
-
const result = await analyzeImageForFace(base64Image);
|
|
40
|
+
const result = await analyzeImageForFace(base64Image, aiAnalyzer, model);
|
|
36
41
|
setState({ isValidating: false, result, error: null });
|
|
37
42
|
return result;
|
|
38
43
|
} catch (error) {
|
|
@@ -41,7 +46,7 @@ export const useFaceDetection = (): UseFaceDetectionReturn => {
|
|
|
41
46
|
setState({ isValidating: false, result: null, error: message });
|
|
42
47
|
throw error;
|
|
43
48
|
}
|
|
44
|
-
}, []);
|
|
49
|
+
}, [aiAnalyzer, model]);
|
|
45
50
|
|
|
46
51
|
const reset = useCallback(() => {
|
|
47
52
|
setState(initialState);
|