added some buttsons
Browse files
app.py
CHANGED
@@ -17,7 +17,10 @@ client = openai.OpenAI(organization='org-eiNl8e4nk93VLQFDb4EBz9JG')
|
|
17 |
#generates an AI description of your character
|
18 |
def describe(names,wis,char,str,int,dex,con):
|
19 |
print(f"hi{names}")
|
20 |
-
|
|
|
|
|
|
|
21 |
prom=f"We're generating Dungeons and Dragons characters for a new campaign, and we need a brief character description, including race"
|
22 |
prom+=f" and class. The character's name is {names} with the following stats: Wisdom: {wis},Charisma:{char},Strength:{str},"
|
23 |
prom+=f"Intelligence:{int},Dexterity:{dex},Constitution:{con}. Describe the character, and then, separated by $$$ give us the "
|
@@ -42,7 +45,32 @@ def describe(names,wis,char,str,int,dex,con):
|
|
42 |
|
43 |
|
44 |
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
|
|
|
|
|
|
46 |
def stat( ndice, dicerank):
|
47 |
# return ndice + dicerank
|
48 |
answer=[]
|
@@ -61,6 +89,7 @@ def stat( ndice, dicerank):
|
|
61 |
with gr.Blocks() as statBlock:
|
62 |
gr.Markdown("Your characters stats")
|
63 |
nameBox = gr.Textbox(label="Your DND character",show_label=True)
|
|
|
64 |
wisBox = gr.Number(label="Wisdom",show_label=True,precision=0,minimum=1,maximum=18)
|
65 |
charBox = gr.Number(label="Charisma",show_label=True,precision=0)
|
66 |
strBox =gr.Number(label="Strength",show_label=True,precision=0)
|
@@ -69,11 +98,16 @@ with gr.Blocks() as statBlock:
|
|
69 |
conBox =gr.Number(label="Constitution",show_label=True,precision=0)
|
70 |
dice = gr.Number(value=4,precision=0,visible=False)
|
71 |
dice.visible = False
|
|
|
72 |
rollButt = gr.Button(value="Roll Stats")
|
73 |
-
|
|
|
74 |
outputBox=gr.Textbox(label="The character",show_label=True)
|
75 |
|
|
|
76 |
rollButt.click(stat, inputs=[dice,gr.Number(value=6, visible=False,precision=0)],outputs=[wisBox,charBox,strBox,intBox,dexBox,conBox])
|
|
|
77 |
statBlock.launch()
|
78 |
|
79 |
|
|
|
|
17 |
#generates an AI description of your character
|
18 |
def describe(names,wis,char,str,int,dex,con):
|
19 |
print(f"hi{names}")
|
20 |
+
if (wis==0) :
|
21 |
+
print(f"set some stats or roll random")
|
22 |
+
exit
|
23 |
+
|
24 |
prom=f"We're generating Dungeons and Dragons characters for a new campaign, and we need a brief character description, including race"
|
25 |
prom+=f" and class. The character's name is {names} with the following stats: Wisdom: {wis},Charisma:{char},Strength:{str},"
|
26 |
prom+=f"Intelligence:{int},Dexterity:{dex},Constitution:{con}. Describe the character, and then, separated by $$$ give us the "
|
|
|
45 |
|
46 |
|
47 |
return result
|
48 |
+
|
49 |
+
#generates an AI description of your character
|
50 |
+
def makeName():
|
51 |
+
|
52 |
+
prom=f"We're generating Dungeons and Dragons characters for a new campaign, and we need a name."
|
53 |
+
prom+=f" Please imagine and give me just a character name for the player to use."
|
54 |
+
completion = client.completions.create(
|
55 |
+
model='gpt-3.5-turbo-instruct',
|
56 |
+
prompt=prom,
|
57 |
+
max_tokens=50,
|
58 |
+
temperature=0.77,
|
59 |
+
frequency_penalty=0.2,
|
60 |
+
presence_penalty= 0.25)
|
61 |
+
|
62 |
+
result =completion.choices[0].text
|
63 |
+
#print(dict(completion).get('usage'))
|
64 |
+
|
65 |
+
|
66 |
+
#print(completion.model_dump_json(indent=2))
|
67 |
+
|
68 |
+
if not result :
|
69 |
+
result = "The Doctor"
|
70 |
|
71 |
+
|
72 |
+
return result
|
73 |
+
|
74 |
def stat( ndice, dicerank):
|
75 |
# return ndice + dicerank
|
76 |
answer=[]
|
|
|
89 |
with gr.Blocks() as statBlock:
|
90 |
gr.Markdown("Your characters stats")
|
91 |
nameBox = gr.Textbox(label="Your DND character",show_label=True)
|
92 |
+
nameButt = gr.Button(value="Random Name")
|
93 |
wisBox = gr.Number(label="Wisdom",show_label=True,precision=0,minimum=1,maximum=18)
|
94 |
charBox = gr.Number(label="Charisma",show_label=True,precision=0)
|
95 |
strBox =gr.Number(label="Strength",show_label=True,precision=0)
|
|
|
98 |
conBox =gr.Number(label="Constitution",show_label=True,precision=0)
|
99 |
dice = gr.Number(value=4,precision=0,visible=False)
|
100 |
dice.visible = False
|
101 |
+
|
102 |
rollButt = gr.Button(value="Roll Stats")
|
103 |
+
describeButt = gr.Button(value="Generate Description")
|
104 |
+
|
105 |
outputBox=gr.Textbox(label="The character",show_label=True)
|
106 |
|
107 |
+
nameButt.click(makeName,inputs=[],outputs=[nameBox])
|
108 |
rollButt.click(stat, inputs=[dice,gr.Number(value=6, visible=False,precision=0)],outputs=[wisBox,charBox,strBox,intBox,dexBox,conBox])
|
109 |
+
describeButt.click(describe, outputs=[outputBox],inputs=[nameBox,wisBox,charBox,strBox,intBox,dexBox,conBox])
|
110 |
statBlock.launch()
|
111 |
|
112 |
|
113 |
+
|