Skip to content
New issue

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

Removed tts for prod #193

Merged
merged 75 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
8d21714
Style: fixed odia title (#104)
prtkjakhar May 9, 2023
beec8fe
Feat chat history (#106)
geeky-abhishek May 9, 2023
69137b3
Delete .env.production
geeky-abhishek May 9, 2023
61e535f
UI changes (#112)
geeky-abhishek May 10, 2023
fb95fbc
fix: conversation id (#115)
geeky-abhishek May 11, 2023
3c16d52
Merge branch 'production' into main
geeky-abhishek May 11, 2023
f9192d4
Added down time page (#117)
prtkjakhar May 11, 2023
091ed6e
Update ContextProvider.tsx (#118)
prtkjakhar May 11, 2023
585157e
Feat dialer popup (#120)
prtkjakhar May 12, 2023
939e319
Merge branch 'production' into main
geeky-abhishek May 12, 2023
ad9f44b
Added Auth header (#122)
prtkjakhar May 12, 2023
425947c
Merge branch 'production' into main
geeky-abhishek May 15, 2023
5db5d56
chore: msgId display for testing (#127)
geeky-abhishek May 16, 2023
ecfa55c
Feat dsply msg (#128)
geeky-abhishek May 16, 2023
e8e157c
Merge branch 'production' into main
geeky-abhishek May 17, 2023
129d6eb
chore: fixed userID bug (#130)
prtkjakhar May 23, 2023
4af2c31
Feat fcm (#133)
prtkjakhar May 23, 2023
b4e863b
fix: update in conversation api (#135)
prtkjakhar May 29, 2023
5caf66f
fix: added firebase event for msg delay (#136)
prtkjakhar May 29, 2023
cd31282
fix: flagsmith init inside useeffect (#140)
geeky-abhishek Jun 1, 2023
5e0760b
Merge branch 'production' into main
geeky-abhishek Jun 1, 2023
8b9f282
Added query log and splash screen log (#143)
prtkjakhar Jun 2, 2023
3c79987
Feat trans (#134)
prtkjakhar Jun 5, 2023
6796a5b
Merge branch 'production' into main
geeky-abhishek Jun 5, 2023
8defe56
Fix: fcm logic updated (#146)
prtkjakhar Jun 7, 2023
8eb2122
Feat: Added example questions to flagsmith (#147)
prtkjakhar Jun 8, 2023
bf0929e
Feat: Feature Pop Up (#148)
prtkjakhar Jun 12, 2023
eaaf5c0
Merge branch 'production' into main
geeky-abhishek Jun 12, 2023
0dfb454
fix: empty feature details bug (#152)
prtkjakhar Jun 12, 2023
13d1d3b
Merge branch 'production' into main
geeky-abhishek Jun 12, 2023
80c4a8b
fix: handled new history api (#157)
prtkjakhar Jun 21, 2023
27cfafd
fix: no internet error for otp verify in offline (#158)
geeky-abhishek Jun 28, 2023
9ad530b
feat:Speech to text added (#114)
geeky-abhishek Sep 8, 2023
4508a91
Fix chat history (#166)
prtkjakhar Sep 13, 2023
0052a3c
modified label.ask_me in or (#167)
prtkjakhar Sep 14, 2023
f59e057
Minor UI fix (#168)
prtkjakhar Sep 14, 2023
9d15259
Minor UI fix (#169)
prtkjakhar Sep 18, 2023
a5159b1
Merge branch 'production' into main
prtkjakhar Sep 18, 2023
3898b8f
Fix odia translations (#171)
prtkjakhar Sep 18, 2023
e4be1dc
welcome text centered (#173)
prtkjakhar Sep 20, 2023
fce0f6f
chat history pdf api updated
prtkjakhar Sep 20, 2023
b4ec921
Merge branch 'production' into main
prtkjakhar Sep 20, 2023
96b75be
pdf opening
prtkjakhar Sep 21, 2023
117aab8
Merge branch 'main' of https://github.com/AmakrushAI/app
prtkjakhar Sep 21, 2023
c6e2c53
Merge branch 'production' into main
prtkjakhar Sep 21, 2023
f508a27
pdfurl defined two times fixed
prtkjakhar Sep 21, 2023
c40debe
added target in anchor
prtkjakhar Sep 21, 2023
84c1c07
added object url back
prtkjakhar Sep 21, 2023
e3f600f
Merge branch 'production' into main
prtkjakhar Sep 21, 2023
fd2a6d7
added pdfUrl back
prtkjakhar Sep 21, 2023
33e177d
merge main
prtkjakhar Sep 21, 2023
b315a6f
Merge branch 'production' into main
prtkjakhar Sep 21, 2023
6d05890
added toast message if no pdf link
prtkjakhar Sep 21, 2023
c958285
minor fixes
prtkjakhar Sep 21, 2023
48e0aa7
Merge branch 'main' of https://github.com/AmakrushAI/app
prtkjakhar Sep 21, 2023
26282ed
Merge branch 'production' into main
prtkjakhar Sep 21, 2023
1accc3f
fixed manual link
prtkjakhar Sep 21, 2023
f0cec7a
added android handshake for sharing
prtkjakhar Sep 21, 2023
cbcc2d1
android handshake function added
prtkjakhar Sep 21, 2023
7bee713
android handshake function added
prtkjakhar Sep 21, 2023
99d8b62
android handshake added
prtkjakhar Sep 21, 2023
d756020
added android handshake function
prtkjakhar Sep 21, 2023
7d2bd79
minor ui fix
prtkjakhar Sep 21, 2023
5e512d7
updated chat history url
prtkjakhar Sep 25, 2023
9eed839
downloaded pdf opening in new tab
prtkjakhar Sep 26, 2023
60d9ac5
added firebase logs for download, share clicks
prtkjakhar Sep 26, 2023
770c89d
Merge branch 'production' into main
prtkjakhar Sep 26, 2023
dc0f2cd
added error handling if shareUrl not implemented in android
prtkjakhar Sep 26, 2023
5d4494b
Merge branch 'production' into main
prtkjakhar Sep 26, 2023
cab4ad2
Updated shareUrl error message in both langs
prtkjakhar Sep 26, 2023
6e99b75
Merge branch 'production' into main
prtkjakhar Sep 26, 2023
a18507c
sending phoneNumber in asr API
prtkjakhar Sep 27, 2023
91b7c4e
ui enhancements
prtkjakhar Oct 6, 2023
e508b87
tts working
prtkjakhar Oct 6, 2023
539b289
removed tts
prtkjakhar Oct 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/amakrushi/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"message.review_submitted": "Review Submitted!",
"message.didnt_receive": "Didn't receive the OTP?",
"message.resend_again": "Resend again",
"message.shareUrl_android_error" : "Share feature coming soon, please download pdf to share",
"message.coming_soon" : "Coming Soon!",
"message.coming_soon_description" : "We are going to launch this feature very soon. Stay tuned!",
"message.dial_description" : "To connect with call centre",
Expand Down
1 change: 1 addition & 0 deletions apps/amakrushi/lang/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"message.wait_minutes": "ଗୋଟିଏ ଥର ପାସୱାର୍ଡ ପଠାଇବା ପୂର୍ବରୁ ଦୟାକରି {countdown} ସେକେଣ୍ଡ ଅପେକ୍ଷା କରନ୍ତୁ |",
"message.resend_again":"ପୁନର୍ବାର ପଠାନ୍ତୁ |",
"message.didnt_receive": "ଗୋଟିଏ ଥର ପାସୱାର୍ଡ ଗ୍ରହଣ କରିନାହାଁନ୍ତି କି?",
"message.shareUrl_android_error" : "ଶେୟାର୍ ଫିଚର୍ ଶୀଘ୍ର ଆସୁଛି, ଦୟାକରି ଶେୟାର୍ କରିବାକୁ pdf ଡାଉନଲୋଡ୍ କରନ୍ତୁ",
"message.coming_soon" : "ଶୀଘ୍ର ଆସୁଅଛି!",
"message.coming_soon_description" : "ଆମେ ଖୁବ୍ ଶୀଘ୍ର ଏହି ଫିଚର ଲଞ୍ଚ କରିବାକୁ ଯାଉଛୁ , ଶୁଣୁ ଥାନ୍ତୁ",
"message.dial_description" : "କଲ୍ ସେଣ୍ଟର ସହିତ ସଂଯୋଗ କରିବାକୁ |",
Expand Down
10 changes: 10 additions & 0 deletions apps/amakrushi/src/assets/icons/speaker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/amakrushi/src/components/HistoryPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const HistoryPage: NextPage = () => {
error.message ===
"Cannot read properties of undefined (reading 'shareUrl')"
) {
toast.success(`${t('message.coming_soon')}`);
toast.success(`${t('message.shareUrl_android_error')}`);
} else toast.error(error.message);

console.error(error);
Expand Down
1 change: 1 addition & 0 deletions apps/amakrushi/src/components/HomePage/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
text-align: left;
font-size: 14px;
font-weight: bold;
margin-top: 2px;
}

.keyboard{
Expand Down
49 changes: 40 additions & 9 deletions apps/amakrushi/src/components/HomePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, {
useContext,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import { NextPage } from 'next';
Expand Down Expand Up @@ -46,6 +47,9 @@ const HomePage: NextPage = () => {
const [inputMsg, setInputMsg] = useState('');
const [showExampleMessages, setShowExampleMessages] = useState(false);
const [showChatBox, setShowChatBox] = useState(false);
const voiceRecorderRef = useRef(null);
const exampleMessagesRef = useRef(null);
const chatBoxButton = useRef(null);

// Show chatbox when audio recorder sends input message
useEffect(() => {
Expand Down Expand Up @@ -97,14 +101,39 @@ const HomePage: NextPage = () => {
setShowExampleMessages(inputValue.length === 0);
};

const handleDocumentClick = useCallback((event: any) => {
const target = event.target;

// Check if clicked outside voiceRecorder and exampleMessages
if (
//@ts-ignore
!voiceRecorderRef.current?.contains(target) &&
//@ts-ignore
!chatBoxButton.current?.contains(target) &&
//@ts-ignore
!exampleMessagesRef.current?.contains(target)
) {
setShowExampleMessages(false);
// setShowChatBox(false);
}
}, []);

useEffect(() => {
document.addEventListener('click', handleDocumentClick);

return () => {
document.removeEventListener('click', handleDocumentClick);
};
}, [handleDocumentClick]);

if (context?.isDown) {
return <DownTimePage />;
} else
return (
<>
<div className={styles.main}>
<div className={styles.main} onClick={handleDocumentClick}>
<div className={styles.title}>{t('label.ask_me')}</div>
<div className={styles.voiceRecorder}>
<div className={styles.voiceRecorder} ref={voiceRecorderRef}>
<RenderVoiceRecorder setInputMsg={setInputMsg} />
</div>
<div
Expand All @@ -113,14 +142,15 @@ const HomePage: NextPage = () => {
(showExampleMessages
? ` ${styles.visible}`
: ` ${styles.invisible}`)
}>
}
ref={exampleMessagesRef}>
{messages?.[0]?.payload?.buttonChoices?.map((choice: any) => {
return (
<button
onClick={() => {
sendMessage(choice.text);
console.log('clicked');
}}
// onClick={() => {
// sendMessage(choice.text);
// console.log('clicked');
// }}
className={styles.buttonChoice}
key={choice.key}>
<Image
Expand All @@ -131,16 +161,17 @@ const HomePage: NextPage = () => {
style={{ marginRight: '2px' }}
/>
{choice.text}
<div className={styles.rightIcon}>
{/* <div className={styles.rightIcon}>
<RightIcon width="35px" color="var(--secondarygreen)" />
</div>
</div> */}
</button>
);
})}
</div>

<form onSubmit={(event) => event?.preventDefault()}>
<div
ref={chatBoxButton}
className={`${
showChatBox
? `${styles.inputBox} ${styles.inputBoxOpen}`
Expand Down
2 changes: 1 addition & 1 deletion apps/amakrushi/src/components/LoginPage/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const LoginPage: React.FC = () => {
<div className={styles.title}>{t("label.title")}</div>

<div className={styles.body}>
<h1>{t("label.welcome")}</h1>
{/* <h1>{t("label.welcome")}</h1> */}

{/* <RadioGroup onChange={setValue} value={value}>
<Radio value="1">{t("label.farmer")}</Radio>
Expand Down
3 changes: 2 additions & 1 deletion apps/amakrushi/src/components/NavBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function NavBar() {
error.message ===
"Cannot read properties of undefined (reading 'shareUrl')"
) {
toast.success(`${t('message.coming_soon')}`);
toast.success(`${t('message.shareUrl_android_error')}`);
} else toast.error(error.message);

console.error(error);
Expand All @@ -122,6 +122,7 @@ function NavBar() {
}
const newConversationId = uuidv4();
sessionStorage.setItem('conversationId', newConversationId);
if(context?.audioElement) context?.audioElement.pause();
context?.setConversationId(newConversationId);
context?.setMessages([]);
context?.setIsMsgReceiving(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const ChatUiWindow: React.FC = () => {
}, [context?.setMessages, context?.fetchIsDown, context?.isDown]);

const normalizedChat = (chats: any): any => {
console.log('in normalized');
console.log('in normalized', chats);
const conversationId = sessionStorage.getItem('conversationId');
const history = chats
.filter(
Expand All @@ -91,6 +91,7 @@ const ChatUiWindow: React.FC = () => {
reaction: item.reaction,
msgId: item.id,
messageId: item.id,
audio_url: item.audioURL
},
].filter(Boolean)
);
Expand Down
16 changes: 15 additions & 1 deletion apps/amakrushi/src/components/chat-message-item/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

.msgFeedback {
display: flex;
align-items: center;
align-items: flex-end;
width: fit-content;
}

Expand Down Expand Up @@ -109,3 +109,17 @@
margin: 1px 5px;
padding: 2px 8px;
}

.msgSpeaker{
display: flex;
align-items: center;
justify-content: space-evenly;
background-color: white;
height: 26px;
width: 40px;
border: 1px solid var(--secondarygreen);
border-radius: 30px;
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
margin-left: auto;
margin-right: 3rem;
}
21 changes: 16 additions & 5 deletions apps/amakrushi/src/components/chat-message-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import styles from './index.module.css';
import { analytics } from '../../utils/firebase';
import { logEvent } from 'firebase/analytics';
import RightIcon from '../../assets/icons/right.jsx';
import CopyText from '../../assets/icons/copy-text.svg';
import SpeakerIcon from '../../assets/icons/speaker.svg';
import MsgThumbsUp from '../../assets/icons/msg-thumbs-up.jsx';
import MsgThumbsDown from '../../assets/icons/msg-thumbs-down.jsx';
import { AppContext } from '../../context';
Expand Down Expand Up @@ -155,6 +155,15 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
[context, t]
);

const handleAudio = (url: any) => {
// console.log(url)
if(url === ''){
toast.error('No audio');
return;
}
context?.playAudio(url);
}

const { content, type } = message;
// console.log('#-debug:', content);
switch (type) {
Expand Down Expand Up @@ -189,10 +198,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
<div
style={{
display: 'flex',
justifyContent:
content?.data?.position === 'left'
? 'space-between'
: 'flex-end',
justifyContent: 'flex-end',
}}>
{content?.data?.position === 'left' &&
flags?.show_msg_id?.enabled && (
Expand Down Expand Up @@ -241,6 +247,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
</div>
) : (
content?.data?.position === 'left' && (
<div style={{display: 'flex', position: 'relative', top: "-10px"}}>
<div className={styles.msgFeedback}>
<div className={styles.msgFeedbackIcons}>
<div
Expand Down Expand Up @@ -273,6 +280,10 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
&nbsp;
<p>{t('message.helpful')}</p>
</div>
{/* <div className={styles.msgSpeaker} onClick={() => handleAudio(content?.data?.audio_url || '')}>
<Image src={SpeakerIcon} width={15} height={15} alt=""/>
</div> */}
</div>
)
)}
</div>
Expand Down
1 change: 1 addition & 0 deletions apps/amakrushi/src/components/menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Menu: FC = () => {
const router = useRouter();

const urlChanger = (link: string) => {
if(context?.audioElement) context?.audioElement.pause();
if (cookies['access_token'] !== undefined) {
if(link === '/history' && context?.loading){
toast.error(`${t("error.wait_new_chat")}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const RenderVoiceRecorder = ({ setInputMsg }) => {

// Append the WAV file to the FormData object
formData.append('file', blob, 'audio.wav');
formData.append('phoneNumber', localStorage.getItem('phoneNumber'));

// Send the WAV data to the API
const resp = await fetch(apiEndpoint + '/aitools/asr', {
Expand Down
31 changes: 31 additions & 0 deletions apps/amakrushi/src/context/ContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,31 @@ const ContextProvider: FC<{
// const [isConnected, setIsConnected] = useState(newSocket?.connected || false);
const [cookie, setCookie, removeCookie] = useCookies();
const [isOnline, setIsOnline] = useState(navigator.onLine);
const [audioElement, setAudioElement] = useState(null);

const playAudio = useMemo(() => {
return (url: string) => {
if (!url) {
console.error('Audio URL not provided.');
return;
}

if(audioElement){
//@ts-ignore
audioElement.pause();
}
const audio = new Audio(url);
audio.play().then(() => {
console.log('Audio played:', url);
}).catch((error) => {
console.error('Error playing audio:', error);
});

// Update the current audio to the new audio element
//@ts-ignore
setAudioElement(audio);
};
}, [audioElement]);

useEffect(() => {
console.log("online")
Expand Down Expand Up @@ -132,6 +157,7 @@ const ContextProvider: FC<{
choices: any;
conversationId: any;
btns?: boolean;
audio_url: string;
};
messageId: string;
};
Expand All @@ -150,6 +176,7 @@ const ContextProvider: FC<{
conversationId: msg?.content?.conversationId,
sentTimestamp: Date.now(),
btns: msg.content.btns,
audio_url: msg.content.audio_url,
...media,
};

Expand Down Expand Up @@ -380,6 +407,8 @@ const ContextProvider: FC<{
fetchIsDown,
showDialerPopup,
setShowDialerPopup,
playAudio,
audioElement
}),
[
locale,
Expand All @@ -400,6 +429,8 @@ const ContextProvider: FC<{
fetchIsDown,
showDialerPopup,
setShowDialerPopup,
playAudio,
audioElement
]
);

Expand Down
1 change: 1 addition & 0 deletions apps/amakrushi/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
margin: 0;
padding: 0;
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
}

body{
Expand Down
2 changes: 1 addition & 1 deletion packages/chat-ui/dist/index.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/chat-ui/es/components/Bubble/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
min-width: 1px; // for IE bug
background: @bubble-left-bg;
border-radius: @bubble-left-border-radius;
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;

&.text,
&.typing {
Expand Down
1 change: 1 addition & 0 deletions packages/chat-ui/src/components/Bubble/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
min-width: 1px; // for IE bug
background: @bubble-left-bg;
border-radius: @bubble-left-border-radius;
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;

&.text,
&.typing {
Expand Down
Loading