Spaces:
Sleeping
Sleeping
xicocdi
commited on
Commit
·
00fe093
1
Parent(s):
d597087
update source messaging
Browse files
app.py
CHANGED
@@ -116,8 +116,18 @@ async def main(message: cl.Message):
|
|
116 |
)
|
117 |
|
118 |
answer = response["answer"]
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
await cl.Message(content=content, author="AI").send()
|
|
|
116 |
)
|
117 |
|
118 |
answer = response["answer"]
|
119 |
+
source_pdf = response["source_documents"][0].metadata["source"]
|
120 |
+
if source_pdf == "Blueprint-for-an-AI-Bill-of-Rights.pdf":
|
121 |
+
source = "Blueprint for an AI Bill of Rights"
|
122 |
+
elif source_pdf == "AI_Risk_Management_Framework.pdf":
|
123 |
+
source = "AI Risk Management Framework"
|
124 |
+
else:
|
125 |
+
source = source_pdf
|
126 |
+
|
127 |
+
page_number = str(response["source_documents"][0].metadata["page"])
|
128 |
+
|
129 |
+
content = (
|
130 |
+
response["answer"] + f"\n\n(**Source**: {source}, **Page**: {page_number})"
|
131 |
+
)
|
132 |
|
133 |
await cl.Message(content=content, author="AI").send()
|