Update app.py
Browse files
app.py
CHANGED
@@ -62,10 +62,10 @@ def chatbot(race, cls, input, localvar):
|
|
62 |
if len(messages) == 1:
|
63 |
input = "start"
|
64 |
if input:
|
65 |
-
message =
|
66 |
messages.append(message)
|
67 |
chat = openai.ChatCompletion.create(
|
68 |
-
model="gpt-3.5-turbo", messages=message,#messages[-2:]
|
69 |
max_tokens=2048,n=1,temperature=0.5,
|
70 |
)
|
71 |
reply = chat.choices[0].message.content
|
@@ -76,9 +76,9 @@ def chatbot(race, cls, input, localvar):
|
|
76 |
localvar['status'] = getStatus(reply)
|
77 |
messages.append({"role": "assistant", "content": reply})
|
78 |
localvar['messages'] = messages
|
79 |
-
return reply, localvar
|
80 |
else:
|
81 |
-
return "please input words!", localvar
|
82 |
|
83 |
def printMessages(messages):
|
84 |
delimiter = '\n'
|
@@ -89,6 +89,6 @@ def printMessages(messages):
|
|
89 |
app = gr.Interface(fn=chatbot, inputs=[gr.Dropdown(["Orc", "Human", "Elf", "Dwarf", "Halfling", "Goliath", "Dragonborn"], value="Orc", label="Race", info="please choose your race:"),
|
90 |
gr.Dropdown(["Warrior", "Mage", "Priest", "Assassin", "Thief", "Paladin", "Archer", "Guardian"], value="Warrior", label="Class", info="please choose the name of the class you wish to play as:"),
|
91 |
gr.Textbox(lines=7, label="You ask and answer questions below", placeholder="Press submit button to start game"), "state"], #Type word 'start game'
|
92 |
-
outputs=[gr.Textbox(label="DND Game Reply", placeholder="Waiting for you press submit button to start play..."), "state"], title="DND Game",#, gr.Textbox(label="History"),
|
93 |
description="DND Game",theme="compact")
|
94 |
app.launch(share=False)
|
|
|
62 |
if len(messages) == 1:
|
63 |
input = "start"
|
64 |
if input:
|
65 |
+
message = {"role": "user", "content": defaultMsg + "(I am an "+race+" "+cls+")( My Current status is as follows :" + localvar['status'] + ") " + defaultMsgEnd + ". \n" + input}
|
66 |
messages.append(message)
|
67 |
chat = openai.ChatCompletion.create(
|
68 |
+
model="gpt-3.5-turbo", messages=[init, message],#messages[-2:]
|
69 |
max_tokens=2048,n=1,temperature=0.5,
|
70 |
)
|
71 |
reply = chat.choices[0].message.content
|
|
|
76 |
localvar['status'] = getStatus(reply)
|
77 |
messages.append({"role": "assistant", "content": reply})
|
78 |
localvar['messages'] = messages
|
79 |
+
return reply, printMessages(messages), localvar
|
80 |
else:
|
81 |
+
return "please input words!", printMessages(messages), localvar
|
82 |
|
83 |
def printMessages(messages):
|
84 |
delimiter = '\n'
|
|
|
89 |
app = gr.Interface(fn=chatbot, inputs=[gr.Dropdown(["Orc", "Human", "Elf", "Dwarf", "Halfling", "Goliath", "Dragonborn"], value="Orc", label="Race", info="please choose your race:"),
|
90 |
gr.Dropdown(["Warrior", "Mage", "Priest", "Assassin", "Thief", "Paladin", "Archer", "Guardian"], value="Warrior", label="Class", info="please choose the name of the class you wish to play as:"),
|
91 |
gr.Textbox(lines=7, label="You ask and answer questions below", placeholder="Press submit button to start game"), "state"], #Type word 'start game'
|
92 |
+
outputs=[gr.Textbox(label="DND Game Reply", placeholder="Waiting for you press submit button to start play..."), gr.Textbox(label="History"), "state"], title="DND Game",#, gr.Textbox(label="History"),
|
93 |
description="DND Game",theme="compact")
|
94 |
app.launch(share=False)
|