We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
[email protected]
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-chatgpt/src/components/ChatGpt.tsx b/node_modules/react-native-chatgpt/src/components/ChatGpt.tsx index f1b3f62..c2ff3e7 100644 --- a/node_modules/react-native-chatgpt/src/components/ChatGpt.tsx +++ b/node_modules/react-native-chatgpt/src/components/ChatGpt.tsx @@ -113,6 +113,7 @@ export default function ChatGpt({ onAccessTokenChange={(token) => { setIsWaitingForJWT(false); setAccessToken(token); + modalRef?.current?.close(); }} onAccumulatedResponse={(result) => callbackRef.current?.(result)} onStreamError={(error) => errorCallbackRef.current?.(error)} diff --git a/node_modules/react-native-chatgpt/src/components/ModalWebView.tsx b/node_modules/react-native-chatgpt/src/components/ModalWebView.tsx index dba7a4d..f85804d 100644 --- a/node_modules/react-native-chatgpt/src/components/ModalWebView.tsx +++ b/node_modules/react-native-chatgpt/src/components/ModalWebView.tsx @@ -44,6 +44,7 @@ type Props = PassedProps & PublicProps; export interface ModalWebViewMethods { open: () => void; + close: () => void; } const ModalWebView = forwardRef<ModalWebViewMethods, Props>( @@ -80,7 +81,7 @@ const ModalWebView = forwardRef<ModalWebViewMethods, Props>( useImperativeHandle(ref, () => ({ open: () => { animateWebView('show'); - }, + },close:()=>{animateWebView('hide');} })); useEffect(() => { diff --git a/node_modules/react-native-chatgpt/src/utils/parseStreamedGptResponse.ts b/node_modules/react-native-chatgpt/src/utils/parseStreamedGptResponse.ts index 736c607..42b9c2d 100644 --- a/node_modules/react-native-chatgpt/src/utils/parseStreamedGptResponse.ts +++ b/node_modules/react-native-chatgpt/src/utils/parseStreamedGptResponse.ts @@ -33,11 +33,17 @@ export default function parseStreamedGptResponse(data: string) { return null; } // @ts-ignore - const response = JSON.parse(sanitizedChunks[sanitizedChunks.length - 1]); - return { - message: response.message.content.parts[0], - messageId: response.message.id, - conversationId: response.conversation_id, - isDone: response.message?.end_turn === true, - }; + for(let i=sanitizedChunks.length-1; i>-1;i--){ + try{ + const response = JSON.parse(sanitizedChunks[i]); + return { + message: response.message.content.parts[0], + messageId: response.message.id, + conversationId: response.conversation_id, + isDone: response.message?.end_turn === true, + }; + }catch(e){ + + } + } }
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
[email protected]
for the project I'm working on.Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: