Sk4467 commited on
Commit
25b40a9
1 Parent(s): 3b3e291

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -5,22 +5,22 @@ import ast
5
  # from gpt import get_chat_completion
6
  import openai
7
  openAiKey = st.text_input(label="Input the openai key", type="password")
8
- # openai.api_key = openAiKey
9
- if openAiKey:
10
- try:
11
- openai.api_key = openAiKey
12
- # Test request to check if the key is valid
13
- openai.ChatCompletion.create(
14
- model="gpt-3.5-turbo",
15
- messages=[
16
- {"role": "system", "content": "You are a helpful assistant."},
17
- {"role": "user", "content": "Test prompt to check OpenAI key validity."}
18
- ]
19
- )
20
- st.success("OpenAI key is valid!")
21
- except Exception as e:
22
- st.write(f"Invalid OpenAI key: {e}")
23
- st.stop()
24
 
25
  def get_chat_completion(prompt, model="gpt-3.5-turbo"):
26
  try:
 
5
  # from gpt import get_chat_completion
6
  import openai
7
  openAiKey = st.text_input(label="Input the openai key", type="password")
8
+ openai.api_key = openAiKey
9
+ # if openAiKey:
10
+ # try:
11
+ # openai.api_key = openAiKey
12
+ # # Test request to check if the key is valid
13
+ # openai.ChatCompletion.create(
14
+ # model="gpt-3.5-turbo",
15
+ # messages=[
16
+ # {"role": "system", "content": "You are a helpful assistant."},
17
+ # {"role": "user", "content": "Test prompt to check OpenAI key validity."}
18
+ # ]
19
+ # )
20
+ # st.success("OpenAI key is valid!")
21
+ # except Exception as e:
22
+ # st.write(f"Invalid OpenAI key: {e}")
23
+ # st.stop()
24
 
25
  def get_chat_completion(prompt, model="gpt-3.5-turbo"):
26
  try: