philmui commited on
Commit
20e4578
·
1 Parent(s): d79cdd9
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -6,9 +6,9 @@ from openai import AsyncOpenAI # importing openai for API usage
6
  import chainlit as cl # importing chainlit for our app
7
  from chainlit.prompt import Prompt, PromptMessage # importing prompt tools
8
  from chainlit.playground.providers import ChatOpenAI # importing ChatOpenAI tools
9
- from dotenv import load_dotenv
10
 
11
- load_dotenv()
12
 
13
  # ChatOpenAI Templates
14
  system_template = """You are a helpful assistant who always speaks in a pleasant tone!
@@ -18,6 +18,8 @@ user_template = """{input}
18
  Think through your response step by step.
19
  """
20
 
 
 
21
 
22
  @cl.on_chat_start # marks a function that will be executed at the start of a user session
23
  async def start_chat():
@@ -37,7 +39,7 @@ async def start_chat():
37
  async def main(message: cl.Message):
38
  settings = cl.user_session.get("settings")
39
 
40
- client = AsyncOpenAI()
41
 
42
  print(message.content)
43
 
 
6
  import chainlit as cl # importing chainlit for our app
7
  from chainlit.prompt import Prompt, PromptMessage # importing prompt tools
8
  from chainlit.playground.providers import ChatOpenAI # importing ChatOpenAI tools
9
+ from dotenv import load_dotenv, find_dotenv
10
 
11
+ load_dotenv(find_dotenv())
12
 
13
  # ChatOpenAI Templates
14
  system_template = """You are a helpful assistant who always speaks in a pleasant tone!
 
18
  Think through your response step by step.
19
  """
20
 
21
+ OPENAI_API_KEY=os.environ.get("OPENAI_API_KEY")
22
+ print(f"OPENAI_API_KEY: {OPENAI_API_KEY}...")
23
 
24
  @cl.on_chat_start # marks a function that will be executed at the start of a user session
25
  async def start_chat():
 
39
  async def main(message: cl.Message):
40
  settings = cl.user_session.get("settings")
41
 
42
+ client = AsyncOpenAI(api_key=OPENAI_API_KEY)
43
 
44
  print(message.content)
45