Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

SpeechGPT project completion #106

Merged
merged 73 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
a2a82af
setup speechgpt project and setup the initial layout
Gaurang-1402 Feb 10, 2023
9bbb57e
complete the initial Conversation Screen
Gaurang-1402 Feb 10, 2023
eae098d
setup backend of openai api call
Gaurang-1402 Feb 10, 2023
9a9527a
turn jsx into components and prepare for backend api call to gpt-3
Gaurang-1402 Feb 10, 2023
8f3f094
build on Gaurang's UI and connect backend with frontend and ensure th…
Sean-Vu Feb 15, 2023
c8c00ca
initial project setup and complete home page + mobile responsive
Sean-Vu Feb 20, 2023
ec79182
complete authentication (Google for now) will implement facebook in t…
Gaurang-1402 Feb 23, 2023
edf2620
complete new chat backend code plus firestore setup
Gaurang-1402 Feb 24, 2023
f13bacf
setup basic chatrow UI
Gaurang-1402 Feb 24, 2023
ba07698
enable fb sign in along with google sign in
Gaurang-1402 Feb 24, 2023
19f9bb3
build on Gaurang's changes and added delete chat functionality and ch…
Sean-Vu Mar 1, 2023
d6f1636
restructure folders and change speechgpt folder name
Gaurang-1402 Mar 2, 2023
c6cb923
complete openai api call setup, firebase admin setup, and test it on …
Gaurang-1402 Mar 3, 2023
3eba11a
complete chat display UI and connect firebase backend updates in chat…
Gaurang-1402 Mar 3, 2023
a84b6aa
complete model selection functionality
Gaurang-1402 Mar 3, 2023
1f6868d
improving the Log in / Sign up page styling
Sean-Vu Mar 5, 2023
7843c68
add styling for Log out button to improve user experience and visual …
Sean-Vu Mar 6, 2023
114ba3e
make UI mobile friendly and responsive, styling better todo
Gaurang-1402 Mar 10, 2023
e0a15d7
add thumbs up / thumbs down UI functionality and relevevant function …
Sean-Vu Mar 10, 2023
1add1db
remake the sidebar with all functionalities
Gaurang-1402 Mar 15, 2023
49de722
Merge branch 'speechGPT-Mobile' of https://github.com/MLH-Fellowship/…
Gaurang-1402 Mar 16, 2023
89947da
make progress on thumbsUp / thumbsDown feature in database
Sean-Vu Mar 16, 2023
04bc009
fix sean doubt regarding db update on thumbsUp
Gaurang-1402 Mar 17, 2023
2592c6f
build on Guarang's changes to update thumbsUp / thumbsDown value to b…
Sean-Vu Mar 17, 2023
6f32bfd
help Guarang
Sean-Vu Mar 17, 2023
cc04a1a
remove modelselection, integrate chatgpt api succesfully, fix small t…
Gaurang-1402 Mar 17, 2023
7685789
add back model selection and style it well
Gaurang-1402 Mar 17, 2023
5dab372
get react code highlighting to work
Gaurang-1402 Mar 17, 2023
7af7352
adjust thumbsUp / thumbsDown feedback
Sean-Vu Mar 17, 2023
165d809
redesign with new styles and UI changes
Sean-Vu Mar 24, 2023
b81f82f
add appropriate logo and text color
Sean-Vu Mar 24, 2023
4c231c1
add contrast to placeholder text in ChatInput component and color upd…
Sean-Vu Mar 24, 2023
e39954b
add contrast to slide out icon
Sean-Vu Mar 24, 2023
2dd48b8
disable image dragging on login page
Sean-Vu Mar 25, 2023
393076d
Merge pull request #1 from MLH-Fellowship/speechGPT-Mobile
Gaurang-1402 Mar 30, 2023
47b95c5
Merge pull request #2 from Gaurang-1402/speechGPT-Mobile
Gaurang-1402 Mar 30, 2023
65e62d6
mobile friendly changes
Sean-Vu Mar 30, 2023
f26c8b2
test to see if deployment updating
Sean-Vu Mar 30, 2023
876497a
allow for chat screen to be seen in collapsed view
Sean-Vu Mar 30, 2023
cc271e2
revert all changes
Sean-Vu Mar 30, 2023
a880d51
get voice typing to work for native chrome version
Gaurang-1402 Mar 31, 2023
5fcc01d
Merge branch 'client-speech-recognition' into speechGPT-Mobile
Gaurang-1402 Mar 31, 2023
687e2cf
minor stylistic changes like color inversion for cohesion
Gaurang-1402 Apr 5, 2023
1ae753c
fix message overflow issue on mobile for code markdown
Sean-Vu Apr 5, 2023
3e536fc
fix message overflow issue on mobile for code markdown
Sean-Vu Apr 5, 2023
62fbd0d
add fix for message overflow issue on mobile for code markdown
Sean-Vu Apr 5, 2023
60831b0
mege sean's stylistic changes with mine
Gaurang-1402 Apr 5, 2023
3dad725
Merge branch 'MLH-Fellowship:speechGPT-Mobile' into speechGPT-Mobile
Gaurang-1402 Apr 5, 2023
3480a56
make some stylistic changes plus small changes in mic integration
Gaurang-1402 Apr 5, 2023
eec6882
Merge branch 'MLH-Fellowship:speechGPT-Mobile' into speechGPT-Mobile
Gaurang-1402 Apr 5, 2023
837ecf6
add package to make deployment work
Gaurang-1402 Apr 5, 2023
422d8c7
Merge branch 'MLH-Fellowship:speechGPT-Mobile' into speechGPT-Mobile
Gaurang-1402 Apr 5, 2023
5a8a5ba
ts ignore to remove typescript errors before deployment
Gaurang-1402 Apr 5, 2023
56b8e9d
Merge branch 'MLH-Fellowship:speechGPT-Mobile' into speechGPT-Mobile
Gaurang-1402 Apr 5, 2023
eeff277
test ts fix for speechRecognition
Gaurang-1402 Apr 5, 2023
7694b5e
Merge branch 'MLH-Fellowship:speechGPT-Mobile' into speechGPT-Mobile
Gaurang-1402 Apr 5, 2023
6802901
try alternative method for speech recognition with react hooks for mo…
Gaurang-1402 Apr 14, 2023
2702f65
Merge pull request #3 from MLH-Fellowship/speechGPT-Mobile
Gaurang-1402 Apr 14, 2023
b39f503
hide trash can icon when sidebar is collapsed
Sean-Vu Apr 14, 2023
8cb6f0b
hide trash can icon when sidebar is collapsed
Sean-Vu Apr 14, 2023
221d4b6
add labgraph logo to webpage tab
Sean-Vu Apr 14, 2023
b3b4261
fix sidebar collapse icon visibility on mobile view
Sean-Vu Apr 14, 2023
933fbf9
Merge branch 'MLH-Fellowship:speechGPT-Mobile' into speechGPT-Mobile
Gaurang-1402 Apr 14, 2023
751a107
Merge pull request #2 from Gaurang-1402/main
Gaurang-1402 May 3, 2023
3115716
Merge branch 'speechGPT-Mobile'
Gaurang-1402 May 3, 2023
3eb7647
Merge pull request #3 from Gaurang-1402/main
Gaurang-1402 May 3, 2023
6afee3a
Update askQuestion.ts
Sean-Vu May 3, 2023
026891b
add google login temporary fix
Gaurang-1402 May 8, 2023
177a609
one more fix
Gaurang-1402 May 8, 2023
f7a8253
cleanup, replace facebook auth
Gaurang-1402 May 18, 2023
a6a11ee
Merge pull request #4 from Gaurang-1402/main
Gaurang-1402 May 18, 2023
37fab93
Update README.md
Gaurang-1402 May 19, 2023
f6fa6db
Update README.md
Gaurang-1402 May 19, 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
38 changes: 38 additions & 0 deletions tree/main/extensions/speechgpt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

serviceAccountKey.json
4 changes: 4 additions & 0 deletions tree/main/extensions/speechgpt/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
90 changes: 90 additions & 0 deletions tree/main/extensions/speechgpt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
## Description

SpeechGPT is a voice-based chat application that enables interaction with powerful large language models. SpeechGPT offers an improved user interface for specific types of queries, allowing users to leverage multiple models from OpenAI, including Ada, Babbage, and GPT-4. Within the context of LabGraph, SpeechGPT is expected to serve as an interface for internal experiments conducted at Meta Reality Labs.

SpeechGPT offers all the features of other chat-based AI application and allows the user to use voice via Speech-to-text to interface with OpenAI models.

Figma design Mockup of the application: https://www.figma.com/file/TCRbyQtfImnXFtnUWqD1dw/SpeechGPT-main?type=design&node-id=1%3A19&t=S3UEHKEKJcURzWKn-1

Project deployed: https://speechgpt-labgraph.vercel.app/

The following project tackles issues #99, #100, #101 and #102. We have set up the SpeechGPT UI with authentication, New chat, delete chat, and chat history functionalities. We have also created the styling theme for this project including the colors, fonts, and common styles using Tailwind CSS. We are using Firebase Firestore as our database and Google authentication.

This is part of a larger project aiming to integrate speech recognition using microphone with chatGPT.

Dependencies

You will have to create a .env.local in the root folder of /tree/main/extensions/speechgpt with the following API keys and credentials:

```
// FACEBOOK
FACEBOOK_APP_ID=...
FACEBOOK_APP_SECRET=...

// NEXTAUTH
NEXTAUTH_URL=...
NEXTAUTH_SECRET=...

// OPENAI
OPENAI_API_KEY =...

// GOOGLE
GOOGLE_APP_ID=...
GOOGLE_APP_SECRET=...


// FIREBASE
FIREBASE_API_KEY=...
FIREBASE_AUTH_DOMAIN=...
FIREBASE_PROJECT_ID=...
FIREBASE_STORAGE_BUCKET=...
FIREBASE_MESSAGE_SENDER_ID=...
FIREBASE_APP_ID=...
FIREBASE_MEASUREMENT_ID=...
FIREBASE_SERVICE_ACCOUNT_KEY= ...

NEXT_PUBLIC_FIREBASE_API_KEY= ...
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN= ...
NEXT_PUBLIC_FIREBASE_PROJECT_ID= ...
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET= ...
NEXT_PUBLIC_FIREBASE_MESSAGE_SENDER_ID= ...
NEXT_PUBLIC_FIREBASE_APP_ID= ...
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID= ...
NEXT_PUBLIC_FIREBASE_SERVICE_ACCOUNT_KEY= ...

```

Next, you will have to install all the dependencies for the UI project. This can be done by running ```npm i``` in the root folder of speechgpt. Here are the dependencies found in speechgpt/package.json

```
  "dependencies": {
    "@heroicons/react": "^2.0.16",
    "classnames": "^2.3.2",
    "firebase-admin": "^11.5.0",
    "heroicons": "^2.0.16",
    "highlight.js": "^11.7.0",
    "next": "latest",
    "next-auth": "^4.19.2",
    "openai": "^3.2.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-firebase-hooks": "^5.1.1",
    "react-hot-toast": "^2.4.0",
    "react-markdown": "^8.0.5",
    "react-select": "^5.7.0",
    "react-speech-recognition": "^3.10.0",
    "react-syntax-highlighter": "^15.5.0",
    "swr": "^2.0.4"
  },
  "devDependencies": {
    "@types/node": "18.11.3",
    "@types/react": "18.0.21",
    "@types/react-dom": "18.0.6",
    "@types/react-speech-recognition": "^3.9.1",
    "@types/react-syntax-highlighter": "^15.5.6",
    "autoprefixer": "^10.4.12",
    "postcss": "^8.4.18",
    "tailwindcss": "^3.2.4",
    "typescript": "4.9.4"
  }
```
18 changes: 18 additions & 0 deletions tree/main/extensions/speechgpt/app/chat/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import Chat from "../../../components/Chat";
import ChatInput from "../../../components/ChatInput";

type Props = {
params: {
id: string
};
};

function ChatPage({params: { id }}: Props){
return <div className="flex flex-col h-screen overflow-hidden">
<Chat chatId = { id } />
<ChatInput chatId = { id } />
</div>
}

export default ChatPage;
9 changes: 9 additions & 0 deletions tree/main/extensions/speechgpt/app/head.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function Head() {
return (
<>
<title>SpeechGPT</title>
<meta content="width=device-width, initial-scale=1" name="viewport" />
<link rel="icon" href="/logo_labgraph_icon.ico" />
</>
)
}
51 changes: 51 additions & 0 deletions tree/main/extensions/speechgpt/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

import SideBar from '../components/SideBar';
import '../styles/globals.css';

import SessionProvider from "../components/SessionProvider"
import { getServerSession } from "next-auth"

import { authOptions } from "../pages/api/auth/[...nextauth]"
import Login from '../components/Login';
import ClientProvider from '../components/ClientProvider';
import SideBarLayout from '../components/SideBarLayout';

import { useState } from 'react';

export default async function RootLayout({
children,
}: {
children: React.ReactNode;
}) {

const session = await getServerSession(authOptions)

// printed in server
// console.log(session);
return (
<html>

<head />
<body>
<SessionProvider session={session}>
{
!session ? (<Login></Login>) :
(
<div className="flex overflow-x-hidden ">
<div className="">
<SideBarLayout />
</div>

<ClientProvider />

<div className="bg-[#ffff] flex-1">{children}</div>
</div>
)

}

</SessionProvider>
</body>
</html>
);
}
53 changes: 53 additions & 0 deletions tree/main/extensions/speechgpt/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

import { BoltIcon, ExclamationTriangleIcon, SunIcon } from '@heroicons/react/24/outline'

function HomePage() {
return (

<div className=" flex flex-col items-center justify-center h-screen
px-2 text-white">
<h1 className="text-5xl font-bold mb-20 text-custom-gray">SpeechGPT</h1>

<div className="flex space-x-2 text-center">
<div>
<div className="flex flex-col items-center justify-center mb-5">
<SunIcon className="h-8 w-8 text-custom-blue" />
<h2>Examples</h2>
</div>

<div className="space-y-2">
<p className="infoText">"Explain Something to me"</p>
<p className="infoText">"What is the difference between a dog and a cat?"</p>
<p className="infoText">"What is the color of the sun?"</p>
</div>
</div>
<div>
<div className="flex flex-col items-center justify-center mb-5">
<BoltIcon className="h-8 w-8 text-custom-blue" />
<h2>Capabilities</h2>
</div>

<div className="space-y-2">
<p className="infoText">Change the SpeechGPT Model to use</p>
<p className="infoText">Messages are stored in Firebase's Firestore</p>
<p className="infoText">Hot Toast notifications when SpeechGPT is thinking!</p>
</div>
</div>
<div>
<div className="flex flex-col items-center justify-center mb-5">
<ExclamationTriangleIcon className="h-8 w-8 text-custom-blue" />
<h2>Limitations</h2>
</div>

<div className="space-y-2">
<p className="infoText">May occasionally generate incorrect information</p>
<p className="infoText">May ocassionally produce harmful instructions or biased content</p>
<p className="infoText">Limited knowledge of world and events after 2021</p>
</div>
</div>
</div>
</div>
)
}

export default HomePage;
35 changes: 35 additions & 0 deletions tree/main/extensions/speechgpt/components/Chat.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"use client"

import { useSession } from "next-auth/react";
import { useCollection } from "react-firebase-hooks/firestore";
import { collection, orderBy, query } from "firebase/firestore"
import { db } from "../firebase"
import Message from "./Message";
import { ArrowDownCircleIcon } from "@heroicons/react/24/solid";

type Props = {
chatId: string;
};

function Chat({ chatId }: Props) {

const { data: session } = useSession()

const [messages] = useCollection(session && query(collection(db, "users", session?.user?.email!, "chats", chatId, "messages"), orderBy("createdAt", "asc")))
return <div className="flex-1 overflow-x-hidden overflow-y-scroll-auto">

{messages?.empty && (
<>
<p className="mt-10 text-center text-custom-gray">
Type a prompt below to get started!
</p>
<ArrowDownCircleIcon className="w-10 h-10 mx-auto mt-5 text-custom-gray animate-bounce"></ArrowDownCircleIcon>
</>
)}
{messages?.docs.map((message) => {
return <Message messageId={message.id} chatId={chatId} message={message.data()} />
})}
</div>
}

export default Chat;
Loading