SwayamAK commited on
Commit
36d40ce
·
1 Parent(s): 2e9ce85
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +4 -7
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .env
app.py CHANGED
@@ -1,9 +1,10 @@
1
  import os
2
-
 
3
  import openai
4
  import gradio
5
 
6
- openai.api_key = "OPENAI_API_KEY"
7
 
8
  messages = [
9
  {"role": "system", "content": "You are a Competitive Programming expert that specializes in coding and Competitive Data structures and Algorithms"}
@@ -14,11 +15,7 @@ def CustomChatGPT(user_input):
14
  response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=messages)
15
  ChatGPT_reply = response["choices"][0]["message"]["content"]
16
  messages.append({"role": "assistant", "content": ChatGPT_reply})
17
-
18
  return ChatGPT_reply
19
 
20
  demo = gradio.Interface(fn=CustomChatGPT, inputs="text", outputs="text", title="CodeGPT")
21
-
22
-
23
-
24
- demo.launch()
 
1
  import os
2
+ from dotenv import load_dotenv
3
+ load_dotenv()
4
  import openai
5
  import gradio
6
 
7
+ openai.api_key = os.getenv("OPENAI_API_KEY")
8
 
9
  messages = [
10
  {"role": "system", "content": "You are a Competitive Programming expert that specializes in coding and Competitive Data structures and Algorithms"}
 
15
  response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=messages)
16
  ChatGPT_reply = response["choices"][0]["message"]["content"]
17
  messages.append({"role": "assistant", "content": ChatGPT_reply})
 
18
  return ChatGPT_reply
19
 
20
  demo = gradio.Interface(fn=CustomChatGPT, inputs="text", outputs="text", title="CodeGPT")
21
+ demo.launch(share=True)