diff --git a/frontend/.env.example b/.env.example similarity index 100% rename from frontend/.env.example rename to .env.example diff --git a/frontend/.eslintrc.json b/.eslintrc.json similarity index 100% rename from frontend/.eslintrc.json rename to .eslintrc.json diff --git a/.gitignore b/.gitignore index d9fbb4b..fd3dbb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,36 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js +.yarn/install-state.gz + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc .DS_Store -.env.local +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/README.md b/README.md index cf86f66..4b776a7 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,25 @@ -# Voice Assistant +# Voice assistant frontend -## Agent +A minimalistic frontend for interacting with [LiveKit Agents](https://docs.livekit.io/agents). -TODO +![Screenshot of the frontend application.](/.github/assets/frontent-screenshot.jpeg) -## Frontend +> [!TIP] +> The best way to test this application along with many others is to use [LiveKit Sandbox](https://cloud.livekit.io/projects/p_/sandbox). Spin up your sandbox in a matter of seconds and test and share your local agents without having to worry about hosting your front end. -![Screenshot of the frontend application.](/.github/assets/frontent-screenshot.jpeg) +## Development setup -> [!NOTE] -> Continue reading only if you plan to modify the frontend app. If you’re just working with the agent code, there’s no need to touch the frontend. Use the hosted sandbox frontend instead. +- Copy and rename `.env.example` to `.env.local`, then add the required environment variables to connect to your LiveKit server. -First, run the development server: +> [!TIP] +> If you are using **LiveKit Cloud**, you can find your project environment variables [here](https://cloud.livekit.io/projects/p_/settings/keys). -```bash -# Frontend code lives in /frontend -cd frontend -# Make sure the frontend dependencies are installed (only required once). +```shell +# Make sure dependencies are installed (only required once). pnpm install # Run den local development server. pnpm dev +# Open http://localhost:3000 in your browser. ``` -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. diff --git a/agent/.env.example b/agent/.env.example deleted file mode 100644 index f79070f..0000000 --- a/agent/.env.example +++ /dev/null @@ -1,6 +0,0 @@ -LIVEKIT_URL= -LIVEKIT_API_KEY= -LIVEKIT_API_SECRET= -ELEVEN_API_KEY= -DEEPGRAM_API_KEY= -OPENAI_API_KEY= diff --git a/agent/.gitignore b/agent/.gitignore deleted file mode 100644 index 819989b..0000000 --- a/agent/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.env.local -venv/ diff --git a/agent/agent.py b/agent/agent.py deleted file mode 100644 index 2e359bf..0000000 --- a/agent/agent.py +++ /dev/null @@ -1,64 +0,0 @@ -import asyncio -import logging - -from dotenv import load_dotenv -from livekit import rtc -from livekit.agents import ( - AutoSubscribe, - JobContext, - JobProcess, - WorkerOptions, - cli, - llm, -) -from livekit.agents.voice_assistant import VoiceAssistant -from livekit.plugins import deepgram, openai, silero - - -load_dotenv(dotenv_path=".env.local") -logger = logging.getLogger("voice-assistant") - - -def prewarm(proc: JobProcess): - proc.userdata["vad"] = silero.VAD.load() - - -async def entrypoint(ctx: JobContext): - initial_ctx = llm.ChatContext().append( - role="system", - text=( - "You are a voice assistant created by LiveKit. Your interface with users will be voice. " - "You should use short and concise responses, and avoiding usage of unpronouncable punctuation. " - "You were created as a demo to showcase the capabilities of LiveKit's agents framework, " - "as well as the ease of development of realtime AI prototypes. You are currently running in a " - "LiveKit Sandbox, which is an environment that allows developers to instantly deploy prototypes " - "of their realtime AI applications to share with others." - ), - ) - - logger.info(f"connecting to room {ctx.room.name}") - await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY) - - # wait for the first participant to connect - participant = await ctx.wait_for_participant() - logger.info(f"starting voice assistant for participant {participant.identity}") - - dg_model = "nova-2-general" - if participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP: - # use a model optimized for telephony - dg_model = "nova-2-phonecall" - - assistant = VoiceAssistant( - vad=ctx.proc.userdata["vad"], - stt=deepgram.STT(model=dg_model), - llm=openai.LLM(), - tts=openai.TTS(), - chat_ctx=initial_ctx, - ) - - assistant.start(ctx.room, participant) - await assistant.say("Hey, how can I help you today?", allow_interruptions=True) - - -if __name__ == "__main__": - cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, prewarm_fnc=prewarm)) diff --git a/agent/requirements.txt b/agent/requirements.txt deleted file mode 100644 index de84f33..0000000 --- a/agent/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -livekit-agents>=0.9.0 -livekit-plugins-openai>=0.8.3 -livekit-plugins-deepgram>=0.6.7 -livekit-plugins-silero>=0.6.4 -python-dotenv~=1.0 -aiofile~=3.8.8 diff --git a/frontend/app/api/connection-details/route.ts b/app/api/connection-details/route.ts similarity index 100% rename from frontend/app/api/connection-details/route.ts rename to app/api/connection-details/route.ts diff --git a/frontend/app/globals.css b/app/globals.css similarity index 100% rename from frontend/app/globals.css rename to app/globals.css diff --git a/frontend/app/layout.tsx b/app/layout.tsx similarity index 100% rename from frontend/app/layout.tsx rename to app/layout.tsx diff --git a/frontend/app/page.tsx b/app/page.tsx similarity index 100% rename from frontend/app/page.tsx rename to app/page.tsx diff --git a/frontend/components/NoAgentNotification.tsx b/components/NoAgentNotification.tsx similarity index 100% rename from frontend/components/NoAgentNotification.tsx rename to components/NoAgentNotification.tsx diff --git a/frontend/.gitignore b/frontend/.gitignore deleted file mode 100644 index fd3dbb5..0000000 --- a/frontend/.gitignore +++ /dev/null @@ -1,36 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts diff --git a/frontend/next.config.mjs b/next.config.mjs similarity index 100% rename from frontend/next.config.mjs rename to next.config.mjs diff --git a/frontend/package.json b/package.json similarity index 100% rename from frontend/package.json rename to package.json diff --git a/frontend/pnpm-lock.yaml b/pnpm-lock.yaml similarity index 100% rename from frontend/pnpm-lock.yaml rename to pnpm-lock.yaml diff --git a/frontend/postcss.config.mjs b/postcss.config.mjs similarity index 100% rename from frontend/postcss.config.mjs rename to postcss.config.mjs diff --git a/frontend/tailwind.config.ts b/tailwind.config.ts similarity index 100% rename from frontend/tailwind.config.ts rename to tailwind.config.ts diff --git a/frontend/tsconfig.json b/tsconfig.json similarity index 100% rename from frontend/tsconfig.json rename to tsconfig.json