starting
Browse files- .gitignore +1 -0
- app.py +23 -5
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.env
|
app.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
import openai
|
3 |
import os
|
|
|
4 |
|
5 |
-
openai.api_key = os.environ['openai']
|
6 |
-
|
7 |
#generates an AI description of your character
|
8 |
-
def describe(names):
|
9 |
print(f"hi{names}")
|
10 |
completion = openai.Completion.create(
|
11 |
engine='text-davinci-003',
|
@@ -24,6 +25,23 @@ def describe(names):
|
|
24 |
|
25 |
|
26 |
|
27 |
-
iface = gr.Interface(fn=describe, inputs=gr.Textbox(label="Your DND character",show_label=True),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
outputs=gr.Textbox(label="The character",show_label=True))
|
29 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import openai
|
3 |
import os
|
4 |
+
import random
|
5 |
|
6 |
+
#openai.api_key = os.environ['openai']
|
7 |
+
openai.api_key = os.getenv('OPENAI_API_KEY')
|
8 |
#generates an AI description of your character
|
9 |
+
def describe(names,wisdom):
|
10 |
print(f"hi{names}")
|
11 |
completion = openai.Completion.create(
|
12 |
engine='text-davinci-003',
|
|
|
25 |
|
26 |
|
27 |
|
28 |
+
iface = gr.Interface(fn=describe, inputs=[gr.Textbox(label="Your DND character",show_label=True),
|
29 |
+
gr.Number(label="Wisdom",show_label=True),
|
30 |
+
gr.Number(label="Charisma",show_label=True),
|
31 |
+
gr.Number(label="Strength",show_label=True),
|
32 |
+
gr.Number(label="Intelligence",show_label=True),
|
33 |
+
gr.Number(label="Dexterity",show_label=True),
|
34 |
+
gr.Number(label="Constitution",show_label=True)],
|
35 |
+
|
36 |
outputs=gr.Textbox(label="The character",show_label=True))
|
37 |
+
iface.launch()
|
38 |
+
|
39 |
+
def stat(n_dice, dice_rank):
|
40 |
+
results = [ # Generate n_dice numbers between [1, dice_rank]
|
41 |
+
random.randint(1, dice_rank)
|
42 |
+
for n
|
43 |
+
in range(n_dice)
|
44 |
+
]
|
45 |
+
lowest = min(results) # Find the lowest roll among the results
|
46 |
+
results.remove(lowest) # Remove the first instance of that lowest roll
|
47 |
+
return sum(results) # Return the sum of the remaining results.
|