Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -66,7 +66,19 @@ class GeminiHandler(AsyncAudioVideoStreamHandler):
|
|
66 |
async def video_emit(self) -> VideoEmitType:
|
67 |
return await self.video_queue.get()
|
68 |
|
69 |
-
async def connect(self, api_key: str,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
if self.session is None:
|
71 |
client = genai.Client(api_key=api_key, http_options={"api_version": "v1alpha"})
|
72 |
config = {"response_modalities": ["AUDIO"], "system_instruction": filled_prompt}
|
@@ -101,7 +113,7 @@ class GeminiHandler(AsyncAudioVideoStreamHandler):
|
|
101 |
if not self.args_set.is_set():
|
102 |
await self.wait_for_args()
|
103 |
if self.session is None:
|
104 |
-
asyncio.create_task(self.connect(self.latest_args[1], self.latest_args[2]))
|
105 |
array = await self.audio_queue.get()
|
106 |
return (self.output_sample_rate, array)
|
107 |
|
@@ -155,21 +167,9 @@ with gr.Blocks(css=css) as demo:
|
|
155 |
benefits = gr.Textbox(label="What we offer", lines=3, placeholder="Describe the benefits offered")
|
156 |
interview_questions = gr.Textbox(label="Interview questions", lines=4, placeholder="Provide interview questions")
|
157 |
|
158 |
-
with open("prompt.md", "r") as file:
|
159 |
-
template = file.read()
|
160 |
-
|
161 |
-
filled_prompt = template.format(
|
162 |
-
about_company=about_company,
|
163 |
-
about_role=about_role,
|
164 |
-
responsibilities=responsibilities,
|
165 |
-
requirements=requirements,
|
166 |
-
benefits=benefits,
|
167 |
-
interview_questions=interview_questions
|
168 |
-
)
|
169 |
-
|
170 |
webrtc.stream(
|
171 |
GeminiHandler(),
|
172 |
-
inputs=[webrtc, api_key,
|
173 |
outputs=[webrtc],
|
174 |
time_limit=90,
|
175 |
concurrency_limit=2,
|
|
|
66 |
async def video_emit(self) -> VideoEmitType:
|
67 |
return await self.video_queue.get()
|
68 |
|
69 |
+
async def connect(self, api_key: str, about_company: str, about_role: str, responsibilities: str, requirements: str, benefits: str, interview_questions: str):
|
70 |
+
with open("prompt.md", "r") as file:
|
71 |
+
template = file.read()
|
72 |
+
|
73 |
+
filled_prompt = template.format(
|
74 |
+
about_company=about_company,
|
75 |
+
about_role=about_role,
|
76 |
+
responsibilities=responsibilities,
|
77 |
+
requirements=requirements,
|
78 |
+
benefits=benefits,
|
79 |
+
interview_questions=interview_questions
|
80 |
+
)
|
81 |
+
|
82 |
if self.session is None:
|
83 |
client = genai.Client(api_key=api_key, http_options={"api_version": "v1alpha"})
|
84 |
config = {"response_modalities": ["AUDIO"], "system_instruction": filled_prompt}
|
|
|
113 |
if not self.args_set.is_set():
|
114 |
await self.wait_for_args()
|
115 |
if self.session is None:
|
116 |
+
asyncio.create_task(self.connect(self.latest_args[1], self.latest_args[2]), self.latest_args[3]), self.latest_args[4]), self.latest_args[5]), self.latest_args[6]), self.latest_args[7]))
|
117 |
array = await self.audio_queue.get()
|
118 |
return (self.output_sample_rate, array)
|
119 |
|
|
|
167 |
benefits = gr.Textbox(label="What we offer", lines=3, placeholder="Describe the benefits offered")
|
168 |
interview_questions = gr.Textbox(label="Interview questions", lines=4, placeholder="Provide interview questions")
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
webrtc.stream(
|
171 |
GeminiHandler(),
|
172 |
+
inputs=[webrtc, api_key, about_company, about_role, responsibilities, requirements, benefits, interview_questions],
|
173 |
outputs=[webrtc],
|
174 |
time_limit=90,
|
175 |
concurrency_limit=2,
|