birkancelik18 commited on
Commit
7d78b60
1 Parent(s): aef5ec5

attack to the memory problem

Browse files
Files changed (2) hide show
  1. .env +2 -0
  2. app.py +8 -3
.env ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ openai_organization_id = "org-YxyhldEv7DjPD7VcbpKcNSB2"
2
+ openai_api_key="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"
app.py CHANGED
@@ -1,10 +1,15 @@
1
  import os
2
  import openai
3
  import gradio
 
 
4
 
 
 
5
  openai.api_key = os.environ["OPENAI_API_KEY"]
6
-
7
- messages = [{"role": "system", "content": "You are an intelligent assistant."}]
 
8
 
9
  def CustomChatGPT(user_input):
10
  messages.append({"role": "user", "content": user_input})
@@ -13,7 +18,7 @@ def CustomChatGPT(user_input):
13
  messages = messages
14
  )
15
  ChatGPT_reply = response["choices"][0]["message"]["content"]
16
- messages.append({"role": "assistant", "content": ChatGPT_reply})
17
  return ChatGPT_reply
18
 
19
  demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "J.A.R.V.I.S.")
 
1
  import os
2
  import openai
3
  import gradio
4
+ import os
5
+ from dotenv import load_dotenv
6
 
7
+ # Load environment variables from the .env file
8
+ #load_dotenv()
9
  openai.api_key = os.environ["OPENAI_API_KEY"]
10
+ #openai.api_key = os.getenv("openai_api_key")
11
+ #openai.organization = os.getenv("openai_organization_id")
12
+ messages = [{"role": "system", "content": "You are an intelligent assistant from Iron Man - your name is J.A.R.V.İ.S-. "}]
13
 
14
  def CustomChatGPT(user_input):
15
  messages.append({"role": "user", "content": user_input})
 
18
  messages = messages
19
  )
20
  ChatGPT_reply = response["choices"][0]["message"]["content"]
21
+ messages.append({"role": "assistant", "content": "You are an intelligent assistant from Iron Man - your name is J.A.R.V.İ.S-. "+ ChatGPT_reply})
22
  return ChatGPT_reply
23
 
24
  demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "J.A.R.V.I.S.")