ZeroTech commited on
Commit
0786583
·
1 Parent(s): 2831493

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -6,6 +6,8 @@ openai.api_key = "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"
6
  messages = [{"role": "system", "content": "You are a financial experts that specializes in real estate investment and negotiation"}]
7
 
8
  def CustomChatGPT(user_input):
 
 
9
  messages.append({"role": "user", "content": user_input})
10
  response = openai.ChatCompletion.create(
11
  model = "gpt-3.5-turbo",
@@ -16,4 +18,4 @@ def CustomChatGPT(user_input):
16
  return ChatGPT_reply
17
 
18
  iface = gr.Interface(fn=CustomChatGPT, inputs="text", outputs="text", title = "ChatBot")
19
- iface.launch(debug = True)
 
6
  messages = [{"role": "system", "content": "You are a financial experts that specializes in real estate investment and negotiation"}]
7
 
8
  def CustomChatGPT(user_input):
9
+ if len(messages) > 10:
10
+ messages.pop(0)
11
  messages.append({"role": "user", "content": user_input})
12
  response = openai.ChatCompletion.create(
13
  model = "gpt-3.5-turbo",
 
18
  return ChatGPT_reply
19
 
20
  iface = gr.Interface(fn=CustomChatGPT, inputs="text", outputs="text", title = "ChatBot")
21
+ iface.launch(debug = True)