king007 commited on
Commit
3e08493
1 Parent(s): 098b79e

Upload 2 files

Browse files
Files changed (2) hide show
  1. faq.py +46 -0
  2. sidebar.py +43 -0
faq.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # flake8: noqa
2
+ import streamlit as st
3
+
4
+
5
+ def faq():
6
+ st.markdown(
7
+ """
8
+ # FAQ
9
+ ## How does KnowledgeGPT work?
10
+ When you upload a document, it will be divided into smaller chunks
11
+ and stored in a special type of database called a vector index
12
+ that allows for semantic search and retrieval.
13
+
14
+ When you ask a question, KnowledgeGPT will search through the
15
+ document chunks and find the most relevant ones using the vector index.
16
+ Then, it will use GPT3 to generate a final answer.
17
+
18
+ ## Is my data safe?
19
+ Yes, your data is safe. KnowledgeGPT does not store your documents or
20
+ questions. All uploaded data is deleted after you close the browser tab.
21
+
22
+ ## Why does it take so long to index my document?
23
+ If you are using a free OpenAI API key, it will take a while to index
24
+ your document. This is because the free API key has strict [rate limits](https://platform.openai.com/docs/guides/rate-limits/overview).
25
+ To speed up the indexing process, you can use a paid API key.
26
+
27
+ ## What do the numbers mean under each source?
28
+ For a PDF document, you will see a citation number like this: 3-12.
29
+ The first number is the page number and the second number is
30
+ the chunk number on that page. For DOCS and TXT documents,
31
+ the first number is set to 1 and the second number is the chunk number.
32
+
33
+ ## Are the answers 100% accurate?
34
+ No, the answers are not 100% accurate. KnowledgeGPT uses GPT-3 to generate
35
+ answers. GPT-3 is a powerful language model, but it sometimes makes mistakes
36
+ and is prone to hallucinations. Also, KnowledgeGPT uses semantic search
37
+ to find the most relevant chunks and does not see the entire document,
38
+ which means that it may not be able to find all the relevant information and
39
+ may not be able to answer all questions (especially summary-type questions
40
+ or questions that require a lot of context from the document).
41
+
42
+ But for most use cases, KnowledgeGPT is very accurate and can answer
43
+ most questions. Always check with the sources to make sure that the answers
44
+ are correct.
45
+ """
46
+ )
sidebar.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ from knowledge_gpt.components.faq import faq
4
+ from dotenv import load_dotenv
5
+ import os
6
+
7
+ load_dotenv()
8
+
9
+
10
+ def sidebar():
11
+ with st.sidebar:
12
+ st.markdown(
13
+ "## How to use\n"
14
+ "1. Enter your [OpenAI API key](https://platform.openai.com/account/api-keys) below🔑\n" # noqa: E501
15
+ "2. Upload a pdf, docx, or txt file📄\n"
16
+ "3. Ask a question about the document💬\n"
17
+ )
18
+ api_key_input = st.text_input(
19
+ "OpenAI API Key",
20
+ type="password",
21
+ placeholder="Paste your OpenAI API key here (sk-...)",
22
+ help="You can get your API key from https://platform.openai.com/account/api-keys.", # noqa: E501
23
+ value=os.environ.get("OPENAI_API_KEY", None)
24
+ or st.session_state.get("OPENAI_API_KEY", ""),
25
+ )
26
+
27
+ st.session_state["OPENAI_API_KEY"] = api_key_input
28
+
29
+ st.markdown("---")
30
+ st.markdown("# About")
31
+ st.markdown(
32
+ "📖KnowledgeGPT allows you to ask questions about your "
33
+ "documents and get accurate answers with instant citations. "
34
+ )
35
+ st.markdown(
36
+ "This tool is a work in progress. "
37
+ "You can contribute to the project on [GitHub](https://github.com/mmz-001/knowledge_gpt) " # noqa: E501
38
+ "with your feedback and suggestions💡"
39
+ )
40
+ st.markdown("Made by [mmz_001](https://twitter.com/mm_sasmitha)")
41
+ st.markdown("---")
42
+
43
+ faq()