Spaces:
Running
Running
Commit
·
1e05855
1
Parent(s):
3688418
Add starting wait message
Browse files
app.py
CHANGED
|
@@ -570,7 +570,8 @@ SPEAKER FORMAT:
|
|
| 570 |
**Speaker Name**
|
| 571 |
....
|
| 572 |
"""
|
| 573 |
-
|
|
|
|
| 574 |
completion = client.chat.completions.create(
|
| 575 |
model="gpt-4o",
|
| 576 |
messages=[
|
|
@@ -1030,19 +1031,33 @@ def create_chat_interface():
|
|
| 1030 |
chatbot_value = [(None, error_message)]
|
| 1031 |
return [chatbot_value, None, None, None, None, None, None, None]
|
| 1032 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1033 |
def stream_initial_analysis(
|
| 1034 |
chatbot_value, transcript_processor, cid, rsid, origin, ct, uid
|
| 1035 |
):
|
| 1036 |
-
if transcript_processor:
|
|
|
|
|
|
|
|
|
|
| 1037 |
for chunk in get_initial_analysis(
|
| 1038 |
transcript_processor, cid, rsid, origin, ct, uid
|
| 1039 |
):
|
|
|
|
| 1040 |
chatbot_value[0] = (None, chunk)
|
| 1041 |
yield chatbot_value
|
| 1042 |
-
|
|
|
|
| 1043 |
yield chatbot_value
|
| 1044 |
|
| 1045 |
-
# Modified load event to handle streaming
|
| 1046 |
demo.load(
|
| 1047 |
on_app_load,
|
| 1048 |
inputs=None,
|
|
@@ -1056,6 +1071,10 @@ def create_chat_interface():
|
|
| 1056 |
turl_state,
|
| 1057 |
uid_state,
|
| 1058 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1059 |
).then(
|
| 1060 |
stream_initial_analysis,
|
| 1061 |
inputs=[
|
|
@@ -1069,7 +1088,6 @@ def create_chat_interface():
|
|
| 1069 |
],
|
| 1070 |
outputs=[chatbot],
|
| 1071 |
)
|
| 1072 |
-
|
| 1073 |
return demo
|
| 1074 |
|
| 1075 |
|
|
|
|
| 570 |
**Speaker Name**
|
| 571 |
....
|
| 572 |
"""
|
| 573 |
+
print("User Prompt is:\n", user_prompt)
|
| 574 |
+
print("System Prompt is:\n", system_prompt)
|
| 575 |
completion = client.chat.completions.create(
|
| 576 |
model="gpt-4o",
|
| 577 |
messages=[
|
|
|
|
| 1031 |
chatbot_value = [(None, error_message)]
|
| 1032 |
return [chatbot_value, None, None, None, None, None, None, None]
|
| 1033 |
|
| 1034 |
+
def display_processing_message(chatbot_value):
|
| 1035 |
+
"""Display the processing message while maintaining state."""
|
| 1036 |
+
# Create new chatbot value with processing message
|
| 1037 |
+
new_chatbot_value = [
|
| 1038 |
+
(None, "Video is being processed. Please wait for the results...")
|
| 1039 |
+
]
|
| 1040 |
+
|
| 1041 |
+
# Return all states to maintain them
|
| 1042 |
+
return new_chatbot_value
|
| 1043 |
+
|
| 1044 |
def stream_initial_analysis(
|
| 1045 |
chatbot_value, transcript_processor, cid, rsid, origin, ct, uid
|
| 1046 |
):
|
| 1047 |
+
if not transcript_processor:
|
| 1048 |
+
return chatbot_value
|
| 1049 |
+
|
| 1050 |
+
try:
|
| 1051 |
for chunk in get_initial_analysis(
|
| 1052 |
transcript_processor, cid, rsid, origin, ct, uid
|
| 1053 |
):
|
| 1054 |
+
# Update the existing message instead of creating a new one
|
| 1055 |
chatbot_value[0] = (None, chunk)
|
| 1056 |
yield chatbot_value
|
| 1057 |
+
except Exception as e:
|
| 1058 |
+
chatbot_value[0] = (None, f"Error during analysis: {str(e)}")
|
| 1059 |
yield chatbot_value
|
| 1060 |
|
|
|
|
| 1061 |
demo.load(
|
| 1062 |
on_app_load,
|
| 1063 |
inputs=None,
|
|
|
|
| 1071 |
turl_state,
|
| 1072 |
uid_state,
|
| 1073 |
],
|
| 1074 |
+
).then(
|
| 1075 |
+
display_processing_message,
|
| 1076 |
+
inputs=[chatbot],
|
| 1077 |
+
outputs=[chatbot],
|
| 1078 |
).then(
|
| 1079 |
stream_initial_analysis,
|
| 1080 |
inputs=[
|
|
|
|
| 1088 |
],
|
| 1089 |
outputs=[chatbot],
|
| 1090 |
)
|
|
|
|
| 1091 |
return demo
|
| 1092 |
|
| 1093 |
|