Spaces:
Runtime error
Runtime error
Retain chatbot history when chatting with video
Browse files- .gitignore +9 -1
- app.py +8 -6
.gitignore
CHANGED
@@ -210,4 +210,12 @@ $RECYCLE.BIN/
|
|
210 |
*.msp
|
211 |
|
212 |
# Windows shortcuts
|
213 |
-
*.lnk
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
*.msp
|
211 |
|
212 |
# Windows shortcuts
|
213 |
+
*.lnk
|
214 |
+
|
215 |
+
.vscode/*
|
216 |
+
|
217 |
+
# Local History for Visual Studio Code
|
218 |
+
.history/
|
219 |
+
|
220 |
+
# Built Visual Studio Code Extensions
|
221 |
+
*.vsix
|
app.py
CHANGED
@@ -2,7 +2,7 @@ import os
|
|
2 |
import random
|
3 |
from dataclasses import dataclass
|
4 |
from time import sleep
|
5 |
-
from typing import Dict, List, Generator
|
6 |
|
7 |
import cv2
|
8 |
import gradio as gr
|
@@ -30,7 +30,7 @@ class MockInterviewer:
|
|
30 |
|
31 |
def chat_with_text(
|
32 |
self,
|
33 |
-
message:
|
34 |
history: List[List],
|
35 |
job_role: str,
|
36 |
company: str,
|
@@ -46,6 +46,7 @@ class MockInterviewer:
|
|
46 |
def chat_with_video(
|
47 |
self,
|
48 |
video: str,
|
|
|
49 |
job_role: str,
|
50 |
company: str,
|
51 |
job_description: str,
|
@@ -53,7 +54,7 @@ class MockInterviewer:
|
|
53 |
technical_count: int,
|
54 |
situational_count: int,
|
55 |
case_count: int
|
56 |
-
) ->
|
57 |
with open(video, 'rb') as file:
|
58 |
transcriptions = self._client.audio.transcriptions.create(
|
59 |
model='whisper-1',
|
@@ -63,7 +64,8 @@ class MockInterviewer:
|
|
63 |
os.remove(video)
|
64 |
config = Config(job_role, company, job_description, behavioral_count, technical_count, situational_count, case_count)
|
65 |
response = self._chat(transcriptions.text, config, video_frame_file_ids)
|
66 |
-
|
|
|
67 |
|
68 |
def clear_thread(self) -> None:
|
69 |
print('Initializing new thread')
|
@@ -204,9 +206,9 @@ with gr.Blocks(theme=theme) as demo:
|
|
204 |
chat_interface.clear_btn.click(mock_interviewer.clear_thread)
|
205 |
|
206 |
with gr.Column(variant='panel', scale=1):
|
207 |
-
video = gr.Video(sources='webcam', include_audio=True)
|
208 |
video.stop_recording(fn=mock_interviewer.chat_with_video,
|
209 |
-
inputs=[video, job_role, company, job_description, behavioral_count, technical_count, situational_count, case_count],
|
210 |
outputs=[chat_interface.chatbot],
|
211 |
api_name=False).then(lambda: None, None, video, queue=False)
|
212 |
|
|
|
2 |
import random
|
3 |
from dataclasses import dataclass
|
4 |
from time import sleep
|
5 |
+
from typing import Dict, List, Generator
|
6 |
|
7 |
import cv2
|
8 |
import gradio as gr
|
|
|
30 |
|
31 |
def chat_with_text(
|
32 |
self,
|
33 |
+
message: str,
|
34 |
history: List[List],
|
35 |
job_role: str,
|
36 |
company: str,
|
|
|
46 |
def chat_with_video(
|
47 |
self,
|
48 |
video: str,
|
49 |
+
history: List[List],
|
50 |
job_role: str,
|
51 |
company: str,
|
52 |
job_description: str,
|
|
|
54 |
technical_count: int,
|
55 |
situational_count: int,
|
56 |
case_count: int
|
57 |
+
) -> List[List]:
|
58 |
with open(video, 'rb') as file:
|
59 |
transcriptions = self._client.audio.transcriptions.create(
|
60 |
model='whisper-1',
|
|
|
64 |
os.remove(video)
|
65 |
config = Config(job_role, company, job_description, behavioral_count, technical_count, situational_count, case_count)
|
66 |
response = self._chat(transcriptions.text, config, video_frame_file_ids)
|
67 |
+
history.append([transcriptions.text, response])
|
68 |
+
return history
|
69 |
|
70 |
def clear_thread(self) -> None:
|
71 |
print('Initializing new thread')
|
|
|
206 |
chat_interface.clear_btn.click(mock_interviewer.clear_thread)
|
207 |
|
208 |
with gr.Column(variant='panel', scale=1):
|
209 |
+
video = gr.Video(sources=['webcam'], include_audio=True)
|
210 |
video.stop_recording(fn=mock_interviewer.chat_with_video,
|
211 |
+
inputs=[video, chat_interface.chatbot_state, job_role, company, job_description, behavioral_count, technical_count, situational_count, case_count],
|
212 |
outputs=[chat_interface.chatbot],
|
213 |
api_name=False).then(lambda: None, None, video, queue=False)
|
214 |
|