Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ruoccofabrizio committed Jul 6, 2023
2 parents b1749c2 + aa2c6d1 commit e943e41
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions backend/utilities/ConfigHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,19 @@ def get_default_config():
{chat_history}
Follow Up Input: {question}
Standalone question:""",
"answering_prompt": """{summaries}
"answering_prompt": """Context:
{summaries}
Please reply to the question using only the information Context section above. If you can't answer a question using the context, reply politely that the information is not in the knowledge base. DO NOT make up your own answers. You detect the language of the question and answer in the same language. If asked for enumerations list all of them and do not invent any.
The context is structured like this:
Please reply to the question using only the information present in the text above.
If you can't find it, reply politely that the information is not in the knowledge base.
Detect the language of the question and answer in the same language.
If asked for enumerations list all of them and do not invent any.
Content: <information>
Source: [url/to/file.pdf](url/to/file.pdf_SAS_TOKEN_PLACEHOLDER_)
<and more of them>
Each source has a name followed by a colon and the actual information, always include the source name for each fact you use in the response. Always use double square brackets to reference the filename source, e.g. [[info1.pdf.txt]]. Don't combine sources, list each source separately, e.g. [[info1.pdf]][[info2.txt]].
When you give your answer, you ALWAYS MUST include the source in your response in the following format: <answer> [[file.pdf]]
Always use double square brackets to reference the filename source, e.g. [[file.pdf]]. When using multiple sources, list each source separately, e.g. [[file1.pdf]][[file2.pdf]].
Question: {question}
Answer:""",
Expand Down
2 changes: 1 addition & 1 deletion backend/utilities/QuestionHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_answer_using_langchain(self, question, chat_history):
break
doc = result["source_documents"][idx]

# Then update the citation object in the response
# Then update the citation object in the response, it needs to have filepath and chunk_id to render in the UI as a file
messages[0]["content"]["citations"].append(
{
"content": doc.page_content,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Answer/Answer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const Answer = ({
const createCitationFilepath = (citation: Citation, index: number, truncate: boolean = false) => {
let citationFilename = "";

if (citation.filepath && citation.chunk_id) {
if (citation.filepath && citation.chunk_id != null) {
if (truncate && citation.filepath.length > filePathTruncationLimit) {
const citationLength = citation.filepath.length;
citationFilename = `${citation.filepath.substring(0, 20)}...${citation.filepath.substring(citationLength -20)} - Part ${parseInt(citation.chunk_id) + 1}`;
Expand Down

0 comments on commit e943e41

Please sign in to comment.