From 033e566986232920eb2d2a2b50d23d30a549a705 Mon Sep 17 00:00:00 2001 From: Yuze Ma Date: Fri, 28 Jul 2023 10:48:01 -0700 Subject: [PATCH] Fixed getting started guidance for people to try out --- README.md | 20 ++++++++++++++------ web_explorer.py | 7 +++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4a72af0..4907e3a 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/web_explorer.py b/web_explorer.py index d2c5a9d..284997b 100644 --- a/web_explorer.py +++ b/web_explorer.py @@ -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():