harrygens commited on
Commit
36c3163
·
1 Parent(s): 27916c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -12,6 +12,7 @@ roleAns = os.environ['roleAns']
12
  classAsk = os.environ['classAsk']
13
  classAns = os.environ['classAns']
14
  defaultMsg = os.environ['defaultMsg']
 
15
 
16
  mod = 3;
17
 
@@ -80,7 +81,7 @@ def chatbot(race, cls, input, localvar):
80
  if len(messages) == 1:
81
  messages.append({"role": "user", "content": input})
82
  else:
83
- messages.append({"role": "user", "content": defaultMsg + localvar['status'] + ". \n" + input})
84
  chat = openai.ChatCompletion.create(
85
  model="gpt-3.5-turbo", messages=messages[-2:],
86
  max_tokens=2048,n=1,temperature=0.5,
@@ -101,7 +102,7 @@ def printMessages(messages):
101
 
102
  app = gr.Interface(fn=chatbot, inputs=[gr.Dropdown(["Orc", "Human", "Elf", "Dwarf", "Halfling", "Goliath", "Dragonborn"], label="Race", info="please choose your race:"),
103
  gr.Dropdown(["Warrior", "Mage", "Priest", "Assassin", "Thief", "Paladin", "Archer", "Guardian"], label="Class", info="please choose the name of the class you wish to play as:"),
104
- gr.Textbox(lines=7, label="You ask and answer questions below", placeholder="Type word "start game" to play"), "state"],
105
  outputs=[gr.Textbox(label="DND Game Reply", placeholder="Waiting for you start..."), gr.Textbox(label="History"), "state"], title="DND Game",#, gr.Textbox(label="History"),
106
  description="DND Game",theme="compact")
107
  app.launch(share=False)
 
12
  classAsk = os.environ['classAsk']
13
  classAns = os.environ['classAns']
14
  defaultMsg = os.environ['defaultMsg']
15
+ defaultMsgEnd = os.environ['defaultMsgEnd']
16
 
17
  mod = 3;
18
 
 
81
  if len(messages) == 1:
82
  messages.append({"role": "user", "content": input})
83
  else:
84
+ messages.append({"role": "user", "content": defaultMsg + "(I am an "+race+" "+cls+")( My Current status is as follows :" + localvar['status'] + ") " + defaultMsgEnd + ". \n" + input})
85
  chat = openai.ChatCompletion.create(
86
  model="gpt-3.5-turbo", messages=messages[-2:],
87
  max_tokens=2048,n=1,temperature=0.5,
 
102
 
103
  app = gr.Interface(fn=chatbot, inputs=[gr.Dropdown(["Orc", "Human", "Elf", "Dwarf", "Halfling", "Goliath", "Dragonborn"], label="Race", info="please choose your race:"),
104
  gr.Dropdown(["Warrior", "Mage", "Priest", "Assassin", "Thief", "Paladin", "Archer", "Guardian"], label="Class", info="please choose the name of the class you wish to play as:"),
105
+ gr.Textbox(lines=7, label="You ask and answer questions below", placeholder="Type word 'start game' to play"), "state"],
106
  outputs=[gr.Textbox(label="DND Game Reply", placeholder="Waiting for you start..."), gr.Textbox(label="History"), "state"], title="DND Game",#, gr.Textbox(label="History"),
107
  description="DND Game",theme="compact")
108
  app.launch(share=False)