openfree commited on
Commit
b0e8b7f
·
verified ·
1 Parent(s): 728ba10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -12,6 +12,11 @@ from aimakerspace.vectordatabase import VectorDatabase
12
  from aimakerspace.openai_utils.chatmodel import ChatOpenAI
13
  import chainlit as cl
14
 
 
 
 
 
 
15
  system_template = """\
16
  Use the following context to answer a users question. If you cannot find the answer in the context, say you don't know the answer."""
17
  system_role_prompt = SystemRolePrompt(system_template)
@@ -111,7 +116,8 @@ async def on_chat_start():
111
  vector_db = VectorDatabase()
112
  vector_db = await vector_db.abuild_from_list(texts)
113
 
114
- chat_openai = ChatOpenAI()
 
115
 
116
  # Create a chain
117
  retrieval_augmented_qa_pipeline = RetrievalAugmentedQAPipeline(
 
12
  from aimakerspace.openai_utils.chatmodel import ChatOpenAI
13
  import chainlit as cl
14
 
15
+ # Get OpenAI API key from environment variables
16
+ openai_api_key = os.getenv("OPENAI_API_KEY")
17
+ if not openai_api_key:
18
+ raise ValueError("OPENAI_API_KEY environment variable is not set")
19
+
20
  system_template = """\
21
  Use the following context to answer a users question. If you cannot find the answer in the context, say you don't know the answer."""
22
  system_role_prompt = SystemRolePrompt(system_template)
 
116
  vector_db = VectorDatabase()
117
  vector_db = await vector_db.abuild_from_list(texts)
118
 
119
+ # Initialize ChatOpenAI with API key from environment variable
120
+ chat_openai = ChatOpenAI(api_key=openai_api_key)
121
 
122
  # Create a chain
123
  retrieval_augmented_qa_pipeline = RetrievalAugmentedQAPipeline(