forked from mmz-001/knowledge_gpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Refactor] move sidebar to components (mmz-001#11)
- Loading branch information
Showing
2 changed files
with
41 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import streamlit as st | ||
|
||
|
||
def set_openai_api_key(api_key: str): | ||
st.session_state["OPENAI_API_KEY"] = api_key | ||
|
||
|
||
def sidebar(): | ||
with st.sidebar: | ||
st.markdown("# About") | ||
st.markdown( | ||
"📖KnowledgeGPT allows you to ask questions about your " | ||
"documents and get accurate answers with instant citations. " | ||
) | ||
st.markdown( | ||
"This tool is a work in progress. " | ||
"You can contribute to the project on [GitHub](https://github.com/mmz-001/knowledge_gpt) " | ||
"with your feedback and suggestions💡" | ||
) | ||
st.markdown("---") | ||
st.markdown( | ||
"## How to use\n" | ||
"1. Enter your [OpenAI API key](https://platform.openai.com/account/api-keys) below🔑\n" | ||
"2. Upload a pdf, docx, or txt file📄\n" | ||
"3. Ask a question about the document💬\n" | ||
) | ||
api_key_input = st.text_input( | ||
"OpenAI API Key", | ||
type="password", | ||
placeholder="Paste your OpenAI API key here (sk-...)", | ||
help="You can get your API key from https://platform.openai.com/account/api-keys.", | ||
value=st.session_state.get("OPENAI_API_KEY", ""), | ||
) | ||
|
||
if api_key_input: | ||
set_openai_api_key(api_key_input) | ||
|
||
st.markdown("---") | ||
st.markdown("Made by [mmz_001](https://twitter.com/mm_sasmitha)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters