diff --git a/apps/slackbot/.env-sample b/apps/slackbot/.env-sample index 4cefc4ac..e38a9d34 100644 --- a/apps/slackbot/.env-sample +++ b/apps/slackbot/.env-sample @@ -1,5 +1,5 @@ # OpenAI. Mandatory. Enables language modeling. -OPENAI_KEY= # OpenAI API key +OPENAI_API_KEY= # OpenAI API key # Serper.dev. Optional. Enables Google web search capability # SERPER_API_KEY= # Serper.dev API key diff --git a/apps/slackbot/bolt_app.py b/apps/slackbot/bolt_app.py index e4d15a59..22d3d7a6 100644 --- a/apps/slackbot/bolt_app.py +++ b/apps/slackbot/bolt_app.py @@ -26,7 +26,7 @@ if cfg.PINECONE_API_KEY is None: print("Setting up local Chroma database") - local_memory = LocalChromaStore.from_folder('files', cfg.OPENAI_KEY).as_retriever() + local_memory = LocalChromaStore.from_folder('files', cfg.OPENAI_API_KEY).as_retriever() ########################################################################### # Define Slack client functionality: @@ -183,13 +183,13 @@ def show_commands_only(logger): def get_response(question, previous_messages): llm = ChatOpenAI( - openai_api_key=cfg.OPENAI_KEY, request_timeout=120 + openai_api_key=cfg.OPENAI_API_KEY, request_timeout=120 ) if cfg.PINECONE_API_KEY: # If pinecone API is specified, then use the Pinecone Database memory = ConversationStore.get_vector_retrieval( - cfg.PINECONE_NAMESPACE, cfg.OPENAI_KEY, index_name=cfg.PINECONE_INDEX, search_type='similarity_score_threshold', search_kwargs={'score_threshold': 0.0} + cfg.PINECONE_NAMESPACE, cfg.OPENAI_API_KEY, index_name=cfg.PINECONE_INDEX, search_type='similarity_score_threshold', search_kwargs={'score_threshold': 0.0} ) else: # use the local Chroma database diff --git a/apps/slackbot/config.py b/apps/slackbot/config.py index 3689a6c0..1f3f51bc 100644 --- a/apps/slackbot/config.py +++ b/apps/slackbot/config.py @@ -24,7 +24,7 @@ SLACK_OAUTH_TOKEN = environ.get('SLACK_OAUTH_TOKEN') SLACK_VERIFICATION_TOKEN = environ.get('SLACK_VERIFICATION_TOKEN') SLACK_PORT = environ.get('SLACK_PORT', 3000) -OPENAI_KEY=environ.get('OPENAI_KEY') +OPENAI_API_KEY=environ.get('OPENAI_API_KEY') PINECONE_API_KEY = environ.get('PINECONE_API_KEY') PINECONE_NAMESPACE = environ.get('PINECONE_NAMESPACE', 'ReadTheDocs') PINECONE_ENV = environ.get('PINECONE_ENV') @@ -42,15 +42,12 @@ else: print('Config: Slack environment variables are set') -if this.OPENAI_KEY is None: +if this.OPENAI_API_KEY is None: print('Config: OpenAI environment variables not set, unable to run') raise SystemExit(1) else: print('Config: OpenAI environment variables are set') -# TODO verify we need OPENAI_API_KEY; can we just use OPENAI_KEY instead? -os.environ['OPENAI_API_KEY'] = this.OPENAI_KEY - if this.PINECONE_API_KEY is None: print('Config: Pinecone environment variables not set') else: diff --git a/apps/slackbot/scrape/extract_github_readme.py b/apps/slackbot/scrape/extract_github_readme.py index 5601c5f9..03d7b5a6 100644 --- a/apps/slackbot/scrape/extract_github_readme.py +++ b/apps/slackbot/scrape/extract_github_readme.py @@ -58,7 +58,7 @@ def extract_github_readme(repo_url): def save_to_pine_cone(content,metadatas): pinecone.init(api_key=cfg.PINECONE_API_KEY, environment=cfg.PINECONE_ENV) index = pinecone.Index("langchain") - embeddings = OpenAIEmbeddings(openai_api_key=cfg.OPENAI_KEY) + embeddings = OpenAIEmbeddings(openai_api_key=cfg.OPENAI_API_KEY) vectorstore = ConversationStore("Github_data", index, embeddings, 'text') vectorstore.add_texts(content,metadatas) \ No newline at end of file diff --git a/apps/slackbot/scrape/prompt_reconstructor.py b/apps/slackbot/scrape/prompt_reconstructor.py index 7fcca668..a8ef34b4 100644 --- a/apps/slackbot/scrape/prompt_reconstructor.py +++ b/apps/slackbot/scrape/prompt_reconstructor.py @@ -38,7 +38,7 @@ def reconstruct_prompt(self): chunk_summary = chunk_and_summerize( link=link, - open_ai_key=cfg.OPENAI_KEY, + open_ai_key=cfg.OPENAI_API_KEY, question=question, text_data=scraped_data["data"] ) @@ -47,7 +47,7 @@ def reconstruct_prompt(self): chunk_summary = chunk_and_summerize( link=link, - open_ai_key=cfg.OPENAI_KEY, + open_ai_key=cfg.OPENAI_API_KEY, question=question, text_data=chunk_summary ) diff --git a/docs/Tutorials/slackbot.rst b/docs/Tutorials/slackbot.rst index 38564255..af96a55b 100644 --- a/docs/Tutorials/slackbot.rst +++ b/docs/Tutorials/slackbot.rst @@ -67,7 +67,7 @@ After you clone the repository, you can find the slackbot project under `apps/sl .. image:: slackbot_imgs/slackbot2.png :width: 400 - * The `OPENAI_KEY` can be found in your OpenAI account page. If you don't have an account, create one at https://platform.openai.com/overview. Remember to upgrade to a paid account after using any free credits you're given by OpenAI, or you will encounter `openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details`. + * The `OPENAI_API_KEY` can be found in your OpenAI account page. If you don't have an account, create one at https://platform.openai.com/overview. Remember to upgrade to a paid account after using any free credits you're given by OpenAI, or you will encounter `openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details`. * Serper is a search engine that we will use to search for relevant articles. You can find the API key in your Serper account page. If you don't have an account, create one at https://serpapi.com/. Serper is optional -- you don't need it to run the app -- but adding Serper will enable the Internet search function of the SlackBot. If you don't want to have this functionality, leave the `SERPER_API_KEY` empty. * You may also find there are *PINECONE_xxx* key/value pairs in the `.env` file. Pinecone is a cloud-based vector database. By default, this app runs with an in-memory (local) vector database called Chroma. However, if you want to build your own cloud vector database with Pinecone, you can learn more about that here: https://www.pinecone.io/. diff --git a/scripts/transcript_summarizer_aws_lambda.py b/scripts/transcript_summarizer_aws_lambda.py index 38e7953a..56f81e62 100644 --- a/scripts/transcript_summarizer_aws_lambda.py +++ b/scripts/transcript_summarizer_aws_lambda.py @@ -24,7 +24,7 @@ # instantiate chat model chat = ChatOpenAI( - openai_api_key=cfg.OPENAI_KEY, + openai_api_key=cfg.OPENAI_API_KEY, temperature=0, model='gpt-3.5-turbo')