Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ dist
# API extractor
temp

# typedoc
docs

# direnv
.direnv

Expand Down
19 changes: 8 additions & 11 deletions agent/voice_agent/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
insufficient_info_excited_end_messages,
insufficient_info_critical_end_messages,
)
from voice_agent.persona_config import (
TIMEOUT_SECONDS,
TIMEOUT_WARNING_TIME,
SPEAK_DELAY,
MAX_CALL_DURATION,
CALL_DURATION_WARNING_TIME,
DEFAULT_VOICE_ID as ELEVENLABS_DEFAULT_VOICE_ID,
)

# Mapping from the room mood prefix to the correct prompts
mood_system_prompts = {
Expand All @@ -26,14 +34,3 @@
"excited": insufficient_info_excited_end_messages,
"critical": insufficient_info_critical_end_messages,
}

# ---- Timing configuration ----
TIMEOUT_SECONDS = 30
TIMEOUT_WARNING_TIME = 10
SPEAK_DELAY = 3
MAX_CALL_DURATION = 200
CALL_DURATION_WARNING_TIME = 100

# ---- ElevenLabs Default Voice ID ----
# Mark - Natural Conversations -> https://elevenlabs.io/app/voice-library?voiceId=UgBBYS2sOqTuMpoF3BR0
ELEVENLABS_DEFAULT_VOICE_ID = "UgBBYS2sOqTuMpoF3BR0"
61 changes: 39 additions & 22 deletions agent/voice_agent/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
from livekit.plugins.elevenlabs import VoiceSettings
from livekit.plugins.turn_detector.english import EnglishModel
import requests
from voice_agent.persona_config import (
VOICE_SPEED,
VOICE_STABILITY,
VOICE_SIMILARITY_BOOST,
VOICE_STYLE,
VOICE_USE_SPEAKER_BOOST,
)
from voice_agent.stt_words import stt_words
from voice_agent.assistant import Assistant, prewarm
from voice_agent.constants import (
Expand Down Expand Up @@ -95,31 +102,41 @@ async def entrypoint(ctx: JobContext): # noqa: C901 – keep high complexity fo
mood = "excited" # sensible default
logger.debug("Conversation mood resolved to '%s'", mood)

try:
room_id = ctx.room.name.split("_")[2]

datalayer_base_url = os.environ.get("DATALAYER_BASE_URL")
datalayer_api_key = os.environ.get("DATALAYER_API_KEY")

if datalayer_base_url and datalayer_api_key:
# Parse room ID from room name (format: <mood>_room_<roomId>)
parts = ctx.room.name.split("_")
if len(parts) >= 3:
room_id = parts[2]
else:
import uuid
room_id = str(uuid.uuid4())
logger.warning(
"Room name '%s' does not contain a room ID – generated fallback: %s",
ctx.room.name,
room_id,
)

# Optional: save initial conversation to analytics backend (Devfolio-specific; forks can ignore)
datalayer_base_url = os.environ.get("DATALAYER_BASE_URL")
datalayer_api_key = os.environ.get("DATALAYER_API_KEY")
datalayer_path = os.environ.get("DATALAYER_PATH", "miscellaneous/jessegpt/conversations")

if datalayer_base_url and datalayer_api_key:
try:
response = requests.post(
f"{datalayer_base_url}miscellaneous/jessegpt/conversations",
f"{datalayer_base_url}{datalayer_path}",
json={
"roomId": room_id,
},
headers={"x_api_key": datalayer_api_key},
)
response.raise_for_status()
logger.info("Successfully saved conversation to database")
else:
logger.info(
"Skipping Devfolio Datalayer API call - required environment variables not defined"
)
except IndexError:
logger.error("Room name does not contain a room ID")
raise ValueError("Room name does not contain a room ID")
except Exception as e:
logger.error(f"Failed to save initial conversation: {e}")
except Exception as e:
logger.error(f"Failed to save initial conversation: {e}")
else:
logger.info(
"Skipping Devfolio Datalayer API call - required environment variables not defined"
)

system_prompt = mood_system_prompts[mood]
greetings = mood_initial_greetings[mood]
Expand All @@ -134,11 +151,11 @@ async def entrypoint(ctx: JobContext): # noqa: C901 – keep high complexity fo
model="eleven_multilingual_v2",
voice_id=os.environ.get("ELEVEN_VOICE_ID", ELEVENLABS_DEFAULT_VOICE_ID),
voice_settings=VoiceSettings(
speed=0.86,
stability=0.3,
similarity_boost=0.7,
style=0.10,
use_speaker_boost=True,
speed=VOICE_SPEED,
stability=VOICE_STABILITY,
similarity_boost=VOICE_SIMILARITY_BOOST,
style=VOICE_STYLE,
use_speaker_boost=VOICE_USE_SPEAKER_BOOST,
),
),
vad=ctx.proc.userdata["vad"],
Expand Down
Loading