Spaces:
Runtime error
Runtime error
waheedwaqar
commited on
Commit
·
c39682e
1
Parent(s):
44f3622
Update app.py
Browse files
app.py
CHANGED
@@ -99,10 +99,11 @@ with gr.Blocks() as demo:
|
|
99 |
def user(user_message, history):
|
100 |
# Get response from QA chain
|
101 |
docs = docsearch.similarity_search(user_message)
|
102 |
-
output = chain({"input_documents": docs, "human_input": user_message}, return_only_outputs=
|
103 |
|
104 |
model_info = get_image_url(user_message)
|
105 |
output_text = output['output_text']
|
|
|
106 |
|
107 |
# Construct the HTML for displaying images
|
108 |
images_html = ""
|
@@ -112,8 +113,13 @@ with gr.Blocks() as demo:
|
|
112 |
images_html += f"Toyota Tundra {model_name.capitalize()} 2023: {image_html}"
|
113 |
|
114 |
# Adding the source link
|
115 |
-
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
history.append((user_message, output_text_with_images))
|
119 |
return gr.update(value=""), history
|
|
|
99 |
def user(user_message, history):
|
100 |
# Get response from QA chain
|
101 |
docs = docsearch.similarity_search(user_message)
|
102 |
+
output = chain({"input_documents": docs, "human_input": user_message}, return_only_outputs=False)
|
103 |
|
104 |
model_info = get_image_url(user_message)
|
105 |
output_text = output['output_text']
|
106 |
+
output_text = re.sub(r'^\W+', '', output_text)
|
107 |
|
108 |
# Construct the HTML for displaying images
|
109 |
images_html = ""
|
|
|
113 |
images_html += f"Toyota Tundra {model_name.capitalize()} 2023: {image_html}"
|
114 |
|
115 |
# Adding the source link
|
116 |
+
if docs[0].page_content == 'nan' or docs[1].page_content == 'nan' or docs[0].page_content == '♪':
|
117 |
+
video_link = ""
|
118 |
+
else:
|
119 |
+
video_link = f"Source: {output['input_documents'][0].metadata['video_link']}"
|
120 |
+
|
121 |
+
|
122 |
+
output_text_with_images = f"{output_text}<br>{images_html}{video_link}"
|
123 |
|
124 |
history.append((user_message, output_text_with_images))
|
125 |
return gr.update(value=""), history
|