ya02 commited on
Commit
3cc9e3d
1 Parent(s): 1315fe8

Read OpenAI key from env

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  import chainlit as cl
 
3
  from langchain_openai import ChatOpenAI
4
  from langchain_community.embeddings import HuggingFaceEmbeddings
5
  from langchain.text_splitter import RecursiveCharacterTextSplitter
@@ -10,8 +11,8 @@ from langchain_community.chat_message_histories import ChatMessageHistory
10
  from langchain.memory import ConversationBufferMemory
11
  from langchain_core.prompts import PromptTemplate
12
 
13
- # Your API key
14
- open_ai_key = "sk-proj-DQPYy7NQXLkgtJDLzrijT3BlbkFJuPuWnU33xKyKxgLQauKO"
15
 
16
  llm = ChatOpenAI(api_key=open_ai_key)
17
 
 
1
  import gradio as gr
2
  import chainlit as cl
3
+ import os
4
  from langchain_openai import ChatOpenAI
5
  from langchain_community.embeddings import HuggingFaceEmbeddings
6
  from langchain.text_splitter import RecursiveCharacterTextSplitter
 
11
  from langchain.memory import ConversationBufferMemory
12
  from langchain_core.prompts import PromptTemplate
13
 
14
+ # Access the OpenAI API key from the environment
15
+ open_ai_key = os.getenv("OPENAI_API_KEY")
16
 
17
  llm = ChatOpenAI(api_key=open_ai_key)
18