Skip to content
This repository was archived by the owner on Nov 4, 2025. It is now read-only.
Merged
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
32 changes: 1 addition & 31 deletions backend/app/api/routers/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def cut_fragment_video(self, path: str, start_ms: int, end_ms: int) -> bool:

def extract_audio_from_video(self, video_path: str) -> str | None:
"""Extract audio from video file and save as WAV with same base filename."""
# Generate audio file path with .wav extension
# Generate audio file path with .wav extensionu
audio_path = video_path.replace(".webm", ".wav")

logger.debug("Extracting audio from %s to %s", video_path, audio_path)
Expand Down Expand Up @@ -439,36 +439,6 @@ async def websocket_video_stream(
if text_data == "audio-ready":
await service.handle_audio_marker()
continue
if text_data is not None:
# Treat any other text frame as a direct user answer (debug mode support)
logger.info(
"Received direct text on WS for interview %s: %s",
interview_id,
text_data[:200],
)
await service.update_state(InterviewSocketState.GENERATING_RESPONSE)
latest_message = await service.submit_user_answer(
interview_id, text_data.strip()
)
if latest_message is None:
logger.warning(
"Failed to submit direct text for interview %s",
interview_id,
)
else:
logger.info(
"Direct text submitted successfully for interview %s",
interview_id,
)
if settings.use_yandex_speech_synthesis:
await service.update_state(
InterviewSocketState.SPEECH_SYNTHESIS
)
await service.send_message_to_user(latest_message)
await service.update_state(
InterviewSocketState.AWAITING_USER_ANSWER
)
continue

if data_bytes and len(data_bytes) > 0:
service.add_video_chunk(data_bytes)
Expand Down
8 changes: 4 additions & 4 deletions backend/app/services/pdf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async def parse_cv(
# Generate JSON schema for precise parsing
json_schema = self._get_cv_json_schema()

result = self.gigachat_client.chat(
result = await self.gigachat_client.achat(
{
"messages": [
{
Expand Down Expand Up @@ -339,7 +339,7 @@ async def parse_vacancy(
# Generate JSON schema for precise parsing
json_schema = self._get_vacancy_json_schema()

result = self.gigachat_client.chat(
result = await self.gigachat_client.achat(
{
"messages": [
{
Expand Down Expand Up @@ -472,7 +472,7 @@ async def analyze_cv_with_gigachat(self, file_id: str, question: str) -> str:
PDFParsingError: If analysis fails
"""
try:
result = self.gigachat_client.chat(
result = await self.gigachat_client.achat(
{
"function_call": "auto",
"messages": [
Expand Down Expand Up @@ -502,7 +502,7 @@ async def analyze_vacancy_with_gigachat(self, file_id: str, question: str) -> st
PDFParsingError: If analysis fails
"""
try:
result = self.gigachat_client.chat(
result = await self.gigachat_client.achat(
{
"function_call": "auto",
"messages": [
Expand Down
17 changes: 17 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ http {
}
}

# WebSocket proxy for /ws/ endpoints
location /ws/ {
proxy_pass http://backend:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# WebSocket specific timeouts
proxy_read_timeout 86400;
proxy_send_timeout 86400;
proxy_connect_timeout 60;
}

# Proxy regular API requests to backend
location /api/ {
proxy_pass http://backend:8000/;
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/interviews/interview-chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ export function InterviewChat({ interviewId }: Props) {
refetchInterval: 1000,
});
const isFinished = interview.data.state === "done";
const { webcamRef, sendAudioReadyMarker, socketState, sendTextMessage } =
useWebcamStreaming(interviewId, {
const { webcamRef, sendAudioReadyMarker, socketState } = useWebcamStreaming(
interviewId,
{
disabled: isFinished,
});
},
);
const candidate = useSuspenseQuery(
candidateQueryOptions(interview.data.candidate_id),
);
Expand Down Expand Up @@ -170,15 +172,13 @@ export function InterviewChat({ interviewId }: Props) {
e.key === "Enter" &&
debugPrompt.trim().length > 0
) {
sendTextMessage(debugPrompt.trim());
setDebugPrompt("");
}
}}
/>
<Button
onClick={() => {
if (debugPrompt.trim().length === 0) return;
sendTextMessage(debugPrompt.trim());
setDebugPrompt("");
}}
>
Expand Down
11 changes: 0 additions & 11 deletions frontend/src/hooks/use-webcam-streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,6 @@ export function useWebcamStreaming(
setSocketState("speech_recognition");
}

/**
* Отправка текстового сообщения напрямую по WebSocket (dev/debug режим)
*/
function sendTextMessage(text: string) {
if (!text) return;
console.log("Sending text message over WS:", text);
sendMessage(text);
setSocketState("generating_response");
}

function startRecording() {
console.log("Attempting to start recording...");
setIsRecording(true);
Expand Down Expand Up @@ -258,7 +248,6 @@ export function useWebcamStreaming(
startRecording,
handleStopRecording,
sendAudioReadyMarker,
sendTextMessage,
socketState,
};
}