demetz commited on
Commit
c362926
·
verified ·
1 Parent(s): 19a9fa3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -20,7 +20,7 @@ def get_top_chunks(query):
20
 
21
  client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.2")
22
 
23
- def respond(message, history, name, char_class, char_alignment):
24
  response = ""
25
  top_chunks = get_top_chunks(message)
26
  context = "\n".join(top_chunks)
@@ -30,7 +30,7 @@ def respond(message, history, name, char_class, char_alignment):
30
  "role": "system",
31
  "content": (
32
  f"You are a chatbot that helps users create characters for role-playing games."
33
- f"The user might also provide the following information, please include their inputs in your response: \n Character name: {name}, Character Class: {char_class}, Character Alignment: {char_alignment}"
34
  f"Use the following knowledge to inform your answers:\n\n{context}\n\n"
35
  "Keep your answers under 300 words."
36
  )
@@ -92,11 +92,20 @@ with gr.Blocks(theme=theme) as chatbot:
92
 
93
  character_name = gr.Textbox(label = "Character Name", placeholder="Type your name here…", info ="optional")
94
  character_class = gr.Dropdown(['Barbarian', 'Bard', 'Cleric', 'Druid', 'Fighter', 'Monk', 'Paladin', 'Ranger', 'Rogue', 'Sorcerer', 'Warlock', 'Wizard'], label="Character Class", info="Choose one or more", multiselect=True)
95
- character_alignment = gr.Radio(["Lawful Good", "Neutral Good", "Chaotic Good", "Lawful Neutral", "True Neutral", "Chaotic Neutral", "Lawful Evil", "Neutral Evil", "Chaotic Evil"], elem_classes="alignment_radio")
 
 
 
 
 
 
 
 
 
96
  with gr.Column(scale=2):
97
  gr.ChatInterface(
98
  fn=respond,
99
- additional_inputs=[character_name, character_class, character_alignment], # Pass name into function!
100
  type="messages",
101
  examples=None
102
  )
 
20
 
21
  client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.2")
22
 
23
+ def respond(message, history, name, char_class, char_alignment, char_race):
24
  response = ""
25
  top_chunks = get_top_chunks(message)
26
  context = "\n".join(top_chunks)
 
30
  "role": "system",
31
  "content": (
32
  f"You are a chatbot that helps users create characters for role-playing games."
33
+ f"The user might also provide the following information, please use the context of their inputs in your response: \n Character name: {name}, Character Class: {char_class}, Character Race: {char_race}, Character Alignment: {char_alignment}. If they don't include all the information, try to create a character that best fits the needs of their campaign party."
34
  f"Use the following knowledge to inform your answers:\n\n{context}\n\n"
35
  "Keep your answers under 300 words."
36
  )
 
92
 
93
  character_name = gr.Textbox(label = "Character Name", placeholder="Type your name here…", info ="optional")
94
  character_class = gr.Dropdown(['Barbarian', 'Bard', 'Cleric', 'Druid', 'Fighter', 'Monk', 'Paladin', 'Ranger', 'Rogue', 'Sorcerer', 'Warlock', 'Wizard'], label="Character Class", info="Choose one or more", multiselect=True)
95
+ character_race = gr.Dropdown([
96
+ "Aarakocra", "Aasimar", "Bugbear", "Centaur", "Changeling", "Dragonborn", "Dwarf", "Elf",
97
+ "Fairy", "Firbolg", "Genasi", "Githyanki", "Githzerai", "Gnome", "Goblin", "Goliath",
98
+ "Half-Elf", "Half-Orc", "Halfling", "Hobgoblin", "Human", "Kenku", "Kobold", "Leonin",
99
+ "Lizardfolk", "Minotaur", "Orc", "Owlin", "Satyr", "Shadar-kai", "Shifter", "Tabaxi",
100
+ "Tiefling", "Tortle", "Triton", "Warforged", "Yuan-ti"
101
+ ], multiselect=True)
102
+ character_alignment = gr.Dropdown(["Lawful Good", "Neutral Good", "Chaotic Good", "Lawful Neutral", "True Neutral", "Chaotic Neutral", "Lawful Evil", "Neutral Evil", "Chaotic Evil"], elem_classes="alignment_radio")
103
+
104
+
105
  with gr.Column(scale=2):
106
  gr.ChatInterface(
107
  fn=respond,
108
+ additional_inputs=[character_name, character_class, character_race, character_alignment], # Pass name into function!
109
  type="messages",
110
  examples=None
111
  )