File size: 1,644 Bytes
68e9609
857d94b
c5d56ba
99ac7e3
68e9609
99ac7e3
 
d3811c5
9f3ddf9
df3c57f
857d94b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68e9609
99ac7e3
 
 
 
 
 
 
 
2db5787
99ac7e3
 
d305a6e
99ac7e3
380e45d
99ac7e3
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import gradio as gr
import openai
import os
import random

#openai.api_key = os.environ['openai']
openai.api_key = os.getenv('OPENAI_API_KEY')
#generates an AI description of your character
def describe(names,wis,char,str,int,dex,con):
	print(f"hi{names}")
	completion = openai.Completion.create(
		engine='text-davinci-003',
		prompt=names,
		max_tokens=210,
		temperature=0.97,
		frequency_penalty=0.2,
		presence_penalty= 0.25,
		top_p=1)

	result =completion.choices[0].text
	if not result :
		result = "Could you be any more boring?"

	return result
        
    

iface = gr.Interface(fn=describe, inputs=[gr.Textbox(label="Your DND character",show_label=True),
                                    gr.Number(label="Wisdom",show_label=True), 
                                    gr.Number(label="Charisma",show_label=True), 
                                    gr.Number(label="Strength",show_label=True), 
                                    gr.Number(label="Intelligence",show_label=True), 
                                    gr.Number(label="Dexterity",show_label=True), 
                                    gr.Number(label="Constitution",show_label=True)], 

            outputs=gr.Textbox(label="The character",show_label=True))
iface.launch()


def stat(n_dice, dice_rank):
    results = [  # Generate n_dice numbers between [1,dice_rank]
        random.randint(1, dice_rank)
        for n
        in range(n_dice)
    ]
    lowest = min(results)  # Find the lowest roll among the results
    results.remove(lowest)  # Remove the first instance of that lowest roll
    return sum(results)  # Return the sum of the remaining results.