Fixed getting started guidance for people to try out

This commit is contained in:
Yuze Ma
2023-07-28 10:48:01 -07:00
parent fd0933748c
commit 033e566986
2 changed files with 21 additions and 6 deletions
+14 -6
View File
@@ -1,7 +1,8 @@
## Web Explorer
# Web Explorer
This is a lightweight app using the [Web Research Retriever](https://github.com/langchain-ai/langchain/pull/8102).
## Setup
You only need to supply a few things.
In `settings()` function, supply:
@@ -12,14 +13,21 @@ In `settings()` function, supply:
To use `st.secrets` set enviorment variables in `.streamlit/secrets.toml` file.
Or, simply set all API keys and remove `st.secrets`:
Or, simply add environemnt variables and remove `st.secrets`:
```
export GOOGLE_API_KEY=xxx
export GOOGLE_CSE_ID=xxx
export OPENAI_API_KEY=xxx
import os
os.environ["GOOGLE_API_KEY"] = "YOUR_API_KEY"
os.environ["GOOGLE_CSE_ID"] = "YOUR_CSE_ID"
os.environ["OPENAI_API_BASE"] = "https://api.openai.com/v1"
os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY"
```
Run:
For `GOOGLE_API_KEY` , you could get it from [this link](https://console.cloud.google.com/apis/api/customsearch.googleapis.com/credentials).
For `GOOGLE_CSE_ID` , you could get it from [this link](https://programmablesearchengine.google.com/)
## Run
```
streamlit run web_explorer.py
```
+7
View File
@@ -3,6 +3,13 @@ from langchain.callbacks.base import BaseCallbackHandler
from langchain.chains import RetrievalQAWithSourcesChain
from langchain.retrievers.web_research import WebResearchRetriever
import os
os.environ["GOOGLE_API_KEY"] = "YOUR_API_KEY" # Get it at https://console.cloud.google.com/apis/api/customsearch.googleapis.com/credentials
os.environ["GOOGLE_CSE_ID"] = "YOUR_CSE_ID" # Get it at https://programmablesearchengine.google.com/
os.environ["OPENAI_API_BASE"] = "https://api.openai.com/v1"
os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY" # Get it at https://beta.openai.com/account/api-keys
st.set_page_config(page_title="Interweb Explorer", page_icon="🌐")
def settings():