Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,14 +21,13 @@ def process_and_generate_post(video_file, social_media_type, progress=gr.Progres
|
|
21 |
progress(0, desc="Initializing...")
|
22 |
|
23 |
# Create a Table, a View, and Computed Columns
|
24 |
-
|
25 |
pxt.drop_dir('directory', force=True)
|
26 |
pxt.create_dir('directory')
|
27 |
|
28 |
t = pxt.create_table(
|
29 |
'directory.video_table', {
|
30 |
-
"video": pxt.
|
31 |
-
"sm_type": pxt.
|
32 |
}
|
33 |
)
|
34 |
|
@@ -39,10 +38,10 @@ def process_and_generate_post(video_file, social_media_type, progress=gr.Progres
|
|
39 |
)
|
40 |
|
41 |
# Create computed columns to store transformations and persist outputs
|
42 |
-
t
|
43 |
-
t
|
44 |
-
t
|
45 |
-
t
|
46 |
|
47 |
progress(0.1, desc="Creating UDFs...")
|
48 |
|
@@ -64,10 +63,10 @@ def process_and_generate_post(video_file, social_media_type, progress=gr.Progres
|
|
64 |
progress(0.2, desc="Calling LLMs")
|
65 |
|
66 |
# # Generate responses using OpenAI's chat completion API
|
67 |
-
t
|
68 |
|
69 |
## Extract the content of the response
|
70 |
-
t
|
71 |
|
72 |
if not video_file:
|
73 |
return "Please upload a video file.", None
|
|
|
21 |
progress(0, desc="Initializing...")
|
22 |
|
23 |
# Create a Table, a View, and Computed Columns
|
|
|
24 |
pxt.drop_dir('directory', force=True)
|
25 |
pxt.create_dir('directory')
|
26 |
|
27 |
t = pxt.create_table(
|
28 |
'directory.video_table', {
|
29 |
+
"video": pxt.Video,
|
30 |
+
"sm_type": pxt.String
|
31 |
}
|
32 |
)
|
33 |
|
|
|
38 |
)
|
39 |
|
40 |
# Create computed columns to store transformations and persist outputs
|
41 |
+
t.add_computed_column(audio=extract_audio(t.video, format='mp3'))
|
42 |
+
t.add_computed_column(metadata=get_metadata(t.audio))
|
43 |
+
t.add_computed_column(transcription=openai.transcriptions(audio=t.audio, model='whisper-1'))
|
44 |
+
t.add_computed_column(transcription_text=t.transcription.text)
|
45 |
|
46 |
progress(0.1, desc="Creating UDFs...")
|
47 |
|
|
|
63 |
progress(0.2, desc="Calling LLMs")
|
64 |
|
65 |
# # Generate responses using OpenAI's chat completion API
|
66 |
+
t.add_computed_column(response=openai.chat_completions(messages=t.message, model='gpt-4o-mini-2024-07-18', max_tokens=500))
|
67 |
|
68 |
## Extract the content of the response
|
69 |
+
t.add_computed_column(answer=t.response.choices[0].message.content)
|
70 |
|
71 |
if not video_file:
|
72 |
return "Please upload a video file.", None
|