Skip to content

Commit

Permalink
feat: added expo device info
Browse files Browse the repository at this point in the history
  • Loading branch information
janrtvld committed Dec 4, 2024
1 parent 050d209 commit 6f306ef
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions apps/easypid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"expo-blur": "^13.0.2",
"expo-constants": "~16.0.2",
"expo-dev-client": "~4.0.16",
"expo-device": "~6.0.2",
"expo-font": "~12.0.7",
"expo-haptics": "~13.0.1",
"expo-image": "~1.13.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
useScaleAnimation,
} from '@package/ui'
import type { DisplayImage } from 'packages/agent/src'
import { isAndroid } from 'packages/app/src'
import { useState } from 'react'
import React from 'react'
import { FadeIn, ZoomIn } from 'react-native-reanimated'
Expand Down Expand Up @@ -41,7 +42,7 @@ export function RequestPurposeSection({ purpose, logo, overAskingResponse }: Req
onPressIn={handlePressIn}
onPressOut={handlePressOut}
onPress={toggleAnalysisModal}
mt="$-2"
mt={isAndroid() ? '$0' : '$-2'}
mb="$4"
>
<MessageBox
Expand Down
15 changes: 10 additions & 5 deletions apps/easypid/src/llm/useLLM.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Device from 'expo-device'
import { useCallback, useEffect, useRef, useState } from 'react'
import { Platform } from 'react-native'
import { LLAMA3_2_1B_QLORA_URL, LLAMA3_2_1B_TOKENIZER } from 'react-native-executorch'
Expand Down Expand Up @@ -161,16 +162,20 @@ export function useCheckIncompleteDownload() {
}, [])
}

// TODO: Add expo-device to check if the device is capable
export function useIsDeviceCapable(): boolean {
// For iOS, check if device is at least iPhone X or newer
// For iOS, check if device is at least iPhone 12 or newer
if (Platform.OS === 'ios') {
return true
const modelId = Device.modelId ?? ''
// iPhone 12 series and newer start with iPhone13 (iPhone12 = iPhone13,2)
return /iPhone1[3-9]/.test(modelId) || /iPhone[2-9][0-9]/.test(modelId)
}

// For Android, check RAM
// For Android, check for minimum 4GB RAM
if (Platform.OS === 'android') {
return true
const totalMemory = Device.totalMemory ?? 0
// totalMemory is in bytes, convert 4GB to bytes (4 * 1024 * 1024 * 1024)
const MIN_REQUIRED_RAM = 4 * 1024 * 1024 * 1024
return totalMemory >= MIN_REQUIRED_RAM
}

return false
Expand Down
19 changes: 19 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6f306ef

Please sign in to comment.