{isRecording ? "Listening" : ""}
150 | {transcript && ( 151 |{transcript}
153 |├── .env ├── bun.lockb ├── src └── app │ ├── favicon.ico │ ├── layout.tsx │ ├── globals.css │ ├── api │ └── chat │ │ └── route.ts │ └── page.tsx ├── next.config.js ├── postcss.config.js ├── .env.example ├── .gitignore ├── tailwind.config.ts ├── tsconfig.json ├── package.json └── README.md /.env: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/developersdigest/multi-llm-siri/HEAD/bun.lockb -------------------------------------------------------------------------------- /src/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/developersdigest/multi-llm-siri/HEAD/src/app/favicon.ico -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = {} 3 | 4 | module.exports = nextConfig 5 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | # https://platform.openai.com/account/api-keys 2 | OPENAI_API_KEY="" 3 | # https://docs.perplexity.ai/docs/getting-started 4 | PERPLEXITY_API_KEY="" -------------------------------------------------------------------------------- /src/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from 'next' 2 | import { Inter } from 'next/font/google' 3 | import './globals.css' 4 | 5 | const inter = Inter({ subsets: ['latin'] }) 6 | 7 | export const metadata: Metadata = { 8 | title: 'Siri-of-Everything', 9 | description: 'Siri for LLMs', 10 | } 11 | 12 | export default function RootLayout({ 13 | children, 14 | }: { 15 | children: React.ReactNode 16 | }) { 17 | return ( 18 | 19 |
{children} 20 | 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | -------------------------------------------------------------------------------- /tailwind.config.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from 'tailwindcss' 2 | 3 | const config: Config = { 4 | content: [ 5 | './src/pages/**/*.{js,ts,jsx,tsx,mdx}', 6 | './src/components/**/*.{js,ts,jsx,tsx,mdx}', 7 | './src/app/**/*.{js,ts,jsx,tsx,mdx}', 8 | ], 9 | theme: { 10 | extend: { 11 | backgroundImage: { 12 | 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))', 13 | 'gradient-conic': 14 | 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))', 15 | }, 16 | }, 17 | }, 18 | plugins: [], 19 | } 20 | export default config 21 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "noEmit": true, 9 | "esModuleInterop": true, 10 | "module": "esnext", 11 | "moduleResolution": "bundler", 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "jsx": "preserve", 15 | "incremental": true, 16 | "plugins": [ 17 | { 18 | "name": "next" 19 | } 20 | ], 21 | "paths": { 22 | "@/*": ["./src/*"] 23 | } 24 | }, 25 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 26 | "exclude": ["node_modules"] 27 | } 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "llm-chatterbox", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "@langchain/community": "^0.0.15", 13 | "@langchain/openai": "^0.0.10", 14 | "api": "^6.1.1", 15 | "dotenv": "^16.3.1", 16 | "langchain": "^0.1.1", 17 | "openai": "^4.24.1", 18 | "next": "14.0.4", 19 | "react": "^18", 20 | "react-dom": "^18" 21 | }, 22 | "devDependencies": { 23 | "@types/node": "^20", 24 | "@types/react": "^18", 25 | "@types/react-dom": "^18", 26 | "autoprefixer": "^10.0.1", 27 | "postcss": "^8", 28 | "tailwindcss": "^3.3.0", 29 | "typescript": "^5" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/app/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | :root { 5 | --foreground-rgb: 0, 0, 0; 6 | --background-start-rgb: 214, 219, 220; 7 | --background-end-rgb: 255, 255, 255; 8 | } 9 | @media (prefers-color-scheme: dark) { 10 | :root { 11 | --foreground-rgb: 255, 255, 255; 12 | --background-start-rgb: 0, 0, 0; 13 | --background-end-rgb: 0, 0, 0; 14 | } 15 | } 16 | body { 17 | color: rgb(var(--foreground-rgb)); 18 | background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb))) rgb(var(--background-start-rgb)); 19 | } 20 | .model-bubble { 21 | position: relative; 22 | } 23 | .prominent-pulse { 24 | animation: prominentPulse 1s ease-in-out infinite; 25 | } 26 | @keyframes prominentPulse { 27 | 0%, 28 | 100% { 29 | transform: scale(1); 30 | } 31 | 50% { 32 | transform: scale(0.8); 33 | } 34 | } 35 | .loading-indicator { 36 | border: 10px solid rgba(255, 255, 255, 0.3); 37 | border-top: 5px solid blue; 38 | border-radius: 50%; 39 | width: 198px; 40 | height: 198px; 41 | animation: spin 2s linear infinite; 42 | position: absolute; 43 | transform: translate(-50%, -50%); 44 | } 45 | @keyframes spin { 46 | 0% { 47 | transform: rotate(0deg); 48 | } 49 | 100% { 50 | transform: rotate(360deg); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The "Siri of Everything" 2 | 3 | This project, aptly named the "Siri of Everything," is a voice recognition and response system. It utilizes a variety of advanced language models like GPT-3.5, GPT-4, and Perplexity to process and respond to voice inputs, akin to having a universal Siri capable of understanding and interacting using multiple AI technologies. 4 | 5 | ## Features 6 | 7 | - Advanced voice recognition capabilities. 8 | - Seamless integration with various language models including GPT-3.5, GPT-4, Mistral, Mixtral, Llama2 and others. 9 | - Dynamic and intelligent response generation with audio output. 10 | - User-friendly interface with toggleable recording states for interaction control. 11 | 12 | ## Setup and Installation 13 | 14 | ### Dependencies 15 | 16 | This project requires: 17 | 18 | - Node.js 19 | - OpenAI API 20 | - Perplexity API 21 | - Langchain OpenAI 22 | - Ollama 23 | 24 | ### Environment Variables 25 | 26 | Before running the project, configure your API keys in the `.env` file: 27 | 28 | #### OpenAI API Key 29 | Get from https://platform.openai.com/account/api-keys 30 | OPENAI_API_KEY="" 31 | 32 | #### Perplexity API Key 33 | Get from https://docs.perplexity.ai/docs/getting-started 34 | PERPLEXITY_API_KEY="" 35 | 36 | ### Installation 37 | 38 | To install the necessary packages, run: 39 | 40 | bun install/npm install 41 | 42 | ### Running the Project 43 | 44 | Start the development server: 45 | 46 | npm run dev 47 | 48 | ## Usage 49 | 50 | Interact with the system using voice commands. The system will capture your speech, process it using the selected AI model, and respond both textually and audibly. 51 | 52 | ## Contributing 53 | 54 | Contributions to enhance the "Siri of Everything" are welcome. Whether it's adding new features, improving existing ones, or fixing bugs, your input is valuable. 55 | 56 | Enjoy using the "Siri of Everything" to explore the capabilities of modern AI language models through voice interactions! 57 | ## Acknowledgements 58 | 59 | Initial setup for basic web voice recognition was inspired by the work found at [sambowenhughes/voice-recording-with-nextjs](https://github.com/sambowenhughes/voice-recording-with-nextjs). A big thank you to them! Don't forget to give them a star and follow on GitHub for their amazing contribution. 60 | 61 | ## Connect and Support 62 | 63 | I'm the developer behind Developers Digest. If you find my work helpful or enjoy what I do, consider supporting me. Here are a few ways you can do that: 64 | 65 | - **Patreon**: Support me on Patreon at [patreon.com/DevelopersDigest](https://www.patreon.com/DevelopersDigest) 66 | - **Buy Me A Coffee**: You can buy me a coffee at [buymeacoffee.com/developersdigest](https://www.buymeacoffee.com/developersdigest) 67 | - **Website**: Check out my website at [developersdigest.tech](https://developersdigest.tech) 68 | - **Github**: Follow me on GitHub at [github.com/developersdigest](https://github.com/developersdigest) 69 | - **Twitter**: Follow me on Twitter at [twitter.com/dev__digest](https://twitter.com/dev__digest) 70 | 71 | Your support is greatly appreciated and helps me continue to develop and maintain free, open-source projects. 72 | -------------------------------------------------------------------------------- /src/app/api/chat/route.ts: -------------------------------------------------------------------------------- 1 | // 0. Import Dependencies 2 | import OpenAI from "openai"; 3 | import dotenv from "dotenv"; 4 | import { OpenAI as LangchainOpenAI } from "@langchain/openai"; 5 | import { Ollama } from "@langchain/community/llms/ollama"; 6 | import api from 'api'; 7 | 8 | // 1. Initialize the Perplexity SDK 9 | const sdk = api('@pplx/v0#rht322clnm9gt25'); 10 | 11 | // 2. Configure environment variables 12 | dotenv.config(); 13 | sdk.auth(process.env.PERPLEXITY_API_KEY); 14 | 15 | // 3. Define the response data structure 16 | interface ResponseData { 17 | data: string; 18 | contentType: string; 19 | model: string; 20 | } 21 | 22 | // 4. Initialize the OpenAI instance 23 | const openai = new OpenAI(); 24 | 25 | // 5. Function to create audio from text 26 | async function createAudio( fullMessage: string, voice: "alloy" | "echo" | "fable" | "onyx" | "nova" | "shimmer") { 27 | const mp3 = await openai.audio.speech.create({ 28 | model: "tts-1", 29 | voice: voice, 30 | input: fullMessage, 31 | }); 32 | const buffer = Buffer.from(await mp3.arrayBuffer()); 33 | return buffer.toString('base64'); 34 | } 35 | 36 | // 6. HTTP POST handler function 37 | export async function POST(req: Request, res: Response): Promise{isRecording ? "Listening" : ""}
150 | {transcript && ( 151 |{transcript}
153 |