SwayamAK commited on
Commit
6d8fc35
·
1 Parent(s): 95a077e

upload app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio
3
+
4
+ openai.api_key = "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"
5
+
6
+ messages = [
7
+ {
8
+ "role": "system",
9
+ "content": "You are a Competitive Programming expert that specializes in coding and Competitive Data structures and Algorithms",
10
+ }
11
+ ]
12
+
13
+
14
+ def CustomChatGPT(user_input):
15
+ messages.append({"role": "user", "content": user_input})
16
+ response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=messages)
17
+ ChatGPT_reply = response["choices"][0]["message"]["content"]
18
+ messages.append({"role": "assistant", "content": ChatGPT_reply})
19
+ return ChatGPT_reply
20
+
21
+
22
+ demo = gradio.Interface(
23
+ fn=CustomChatGPT, inputs="text", outputs="text", title="CodeGPT"
24
+ )
25
+
26
+ demo.launch(share=True)