()
| 7 | |
| 8 | |
| 9 | def side_bar() -> None: |
| 10 | with st.sidebar: |
| 11 | with st.expander(':orange[How to use?]'): |
| 12 | st.markdown( |
| 13 | """ |
| 14 | 1. Enter your API keys: (You can use the `gpt4free` free model **without API keys**) |
| 15 | * `OpenAI API Key`: Make sure you still have usage left |
| 16 | * `SERPAPI API Key`: Optional. If you want to ask questions about content not appearing in the PDF document, you need this key. |
| 17 | 2. **Upload a Document** file (choose one method): |
| 18 | * method1: Browse and upload your own document file from your local machine. |
| 19 | * method2: Enter the document URL link directly. |
| 20 | |
| 21 | (**support documents**: `.pdf`, `.docx`, `.csv`, `.txt`) |
| 22 | 3. Start asking questions! |
| 23 | 4. More details.(https://github.com/Lin-jun-xiang/docGPT-streamlit) |
| 24 | 5. If you have any questions, feel free to leave comments and engage in discussions.(https://github.com/Lin-jun-xiang/docGPT-streamlit/issues) |
| 25 | """ |
| 26 | ) |
| 27 | |
| 28 | with st.sidebar: |
| 29 | if st.session_state.openai_api_key: |
| 30 | OPENAI_API_KEY = st.session_state.openai_api_key |
| 31 | st.sidebar.success('API key loaded form previous input') |
| 32 | else: |
| 33 | OPENAI_API_KEY = st.sidebar.text_input( |
| 34 | label='#### Your OpenAI API Key 👇', |
| 35 | placeholder="sk-...", |
| 36 | type="password", |
| 37 | key='OPENAI_API_KEY' |
| 38 | ) |
| 39 | st.session_state.openai_api_key = OPENAI_API_KEY |
| 40 | |
| 41 | os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY |
| 42 | |
| 43 | with st.sidebar: |
| 44 | if st.session_state.serpapi_api_key: |
| 45 | SERPAPI_API_KEY = st.session_state.serpapi_api_key |
| 46 | st.sidebar.success('API key loaded form previous input') |
| 47 | else: |
| 48 | SERPAPI_API_KEY = st.sidebar.text_input( |
| 49 | label='#### Your SERPAPI API Key 👇', |
| 50 | placeholder="...", |
| 51 | type="password", |
| 52 | key='SERPAPI_API_KEY' |
| 53 | ) |
| 54 | st.session_state.serpapi_api_key = SERPAPI_API_KEY |
| 55 | |
| 56 | os.environ['SERPAPI_API_KEY'] = SERPAPI_API_KEY |
| 57 | |
| 58 | with st.sidebar: |
| 59 | gpt4free = GPT4Free() |
| 60 | st.session_state.g4f_provider = st.selectbox( |
| 61 | ( |
| 62 | "#### Select a provider if you want to use free model. " |
| 63 | "([details](https://github.com/xtekky/gpt4free#models))" |
| 64 | ), |
| 65 | (['BestProvider'] + list(gpt4free.providers_table.keys())) |
| 66 | ) |
nothing calls this directly
no test coverage detected