Spaces:
Sleeping
Sleeping
Kim Adams commited on
Commit ·
6960ade
1
Parent(s): 9f2e5c8
updates
Browse files- __pycache__/ui_holder.cpython-311.pyc +0 -0
- app.py +6 -67
- create_games/__pycache__/create_games_slack.cpython-311.pyc +0 -0
- create_games/create_games_slack.py +93 -72
- create_games/data/game_ideas.json +4 -3
- home_view/__pycache__/app_theme.cpython-311.pyc +0 -0
- home_view/__pycache__/ui_home.cpython-311.pyc +0 -0
- home_view/app_theme.py +55 -0
- home_view/art/buildPlay.svg +16 -0
- home_view/ui_home.py +85 -0
- players/ui_players.py +0 -0
- sketch/__pycache__/sketch.cpython-311.pyc +0 -0
- sketch/__pycache__/ui_sketch.cpython-311.pyc +0 -0
- sketch/class_names.txt +100 -0
- sketch/pytorch_model.bin +3 -0
- sketch/sketch.py +49 -0
- slack_processing/__pycache__/theme.cpython-311.pyc +0 -0
- ui_holder.py +80 -0
__pycache__/ui_holder.cpython-311.pyc
ADDED
|
Binary file (6.95 kB). View file
|
|
|
app.py
CHANGED
|
@@ -1,76 +1,15 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import openai
|
| 3 |
-
import
|
| 4 |
-
from huggingface_hub import Repository
|
| 5 |
-
from io import BytesIO
|
| 6 |
-
from dotenv import load_dotenv
|
| 7 |
-
from openai.embeddings_utils import get_embedding, cosine_similarity
|
| 8 |
-
from slack_processing.slack_data_prep import FetchSlack, ProcessSlack, CreateEmbeddings
|
| 9 |
-
from create_games.create_games_slack import CreateGames
|
| 10 |
from utilities import api_keys
|
| 11 |
-
import
|
| 12 |
-
dotenv_version = pkg_resources.get_distribution("tiktoken").version
|
| 13 |
-
print(f"tiktoken version: {dotenv_version}")
|
| 14 |
|
| 15 |
openai.api_key = api_keys.APIKeys().get_key('OPENAI_API_KEY')
|
| 16 |
eleven_api_key = api_keys.APIKeys().get_key('ELEVEN_LABS_API_KEY')
|
| 17 |
voice_id = api_keys.APIKeys().get_key('VOICE_ID')
|
| 18 |
|
| 19 |
-
def FetchSlackJSON():
|
| 20 |
-
result=FetchSlack()
|
| 21 |
-
print("slack fetch")
|
| 22 |
-
print (result)
|
| 23 |
-
return result
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
print("slack processed")
|
| 28 |
-
print (result)
|
| 29 |
-
return result
|
| 30 |
|
| 31 |
-
|
| 32 |
-
result = CreateEmbeddings()
|
| 33 |
-
print("fetch embeddings")
|
| 34 |
-
print(result)
|
| 35 |
-
return result
|
| 36 |
-
|
| 37 |
-
def FetchGames():
|
| 38 |
-
result = CreateGames()
|
| 39 |
-
print("result")
|
| 40 |
-
print(result)
|
| 41 |
-
return result
|
| 42 |
-
|
| 43 |
-
with gr.Blocks() as ui1:
|
| 44 |
-
with gr.Row():
|
| 45 |
-
b1 = gr.Button("Fetch Slack JSON")
|
| 46 |
-
with gr.Row():
|
| 47 |
-
with gr.Column(scale=1, min_width=600):
|
| 48 |
-
df1 =gr.Dataframe(type="pandas")
|
| 49 |
-
b1.click(FetchSlackJSON,outputs=df1)
|
| 50 |
-
|
| 51 |
-
with gr.Blocks() as ui2:
|
| 52 |
-
with gr.Row():
|
| 53 |
-
b2 = gr.Button("Process & Tag Slack Data")
|
| 54 |
-
with gr.Row():
|
| 55 |
-
with gr.Column(scale=1, min_width=600):
|
| 56 |
-
df2 =gr.Dataframe(type="pandas")
|
| 57 |
-
b2.click(ProcessSlack,outputs=df2)
|
| 58 |
-
|
| 59 |
-
with gr.Blocks() as ui3:
|
| 60 |
-
with gr.Row():
|
| 61 |
-
b3 = gr.Button("Create Embeddings")
|
| 62 |
-
with gr.Row():
|
| 63 |
-
with gr.Column(scale=1, min_width=600):
|
| 64 |
-
df3 =gr.Dataframe(type="pandas")
|
| 65 |
-
b3.click(FetchEmbeddings,outputs=df3)
|
| 66 |
-
|
| 67 |
-
with gr.Blocks() as ui4:
|
| 68 |
-
with gr.Row():
|
| 69 |
-
b4 = gr.Button("Find Games")
|
| 70 |
-
with gr.Row():
|
| 71 |
-
with gr.Column(scale=1, min_width=600):
|
| 72 |
-
df4 =gr.Dataframe(type="pandas")
|
| 73 |
-
b4.click(FetchGames,outputs=df4)
|
| 74 |
-
|
| 75 |
-
demo = gr.TabbedInterface([ui1,ui2,ui3,ui4], ("Fetch Slack", "Process & Tag", "Create Embeddings", "Find Games"))
|
| 76 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import openai
|
| 3 |
+
from home_view import ui_home as home
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
from utilities import api_keys
|
| 5 |
+
from sketch import sketch
|
|
|
|
|
|
|
| 6 |
|
| 7 |
openai.api_key = api_keys.APIKeys().get_key('OPENAI_API_KEY')
|
| 8 |
eleven_api_key = api_keys.APIKeys().get_key('ELEVEN_LABS_API_KEY')
|
| 9 |
voice_id = api_keys.APIKeys().get_key('VOICE_ID')
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
combo=home.combo
|
| 13 |
+
combo.launch()
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
#ui_sketch.ui.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
create_games/__pycache__/create_games_slack.cpython-311.pyc
CHANGED
|
Binary files a/create_games/__pycache__/create_games_slack.cpython-311.pyc and b/create_games/__pycache__/create_games_slack.cpython-311.pyc differ
|
|
|
create_games/create_games_slack.py
CHANGED
|
@@ -14,6 +14,7 @@ OUTPUT_GAME_IDEAS_DATAPATH="create_games/data/game_ideas.json"
|
|
| 14 |
themes = []
|
| 15 |
themes_by_person={}
|
| 16 |
people_by_theme = {}
|
|
|
|
| 17 |
|
| 18 |
def ReadThemesFromFile():
|
| 19 |
global themes
|
|
@@ -23,8 +24,6 @@ def ReadThemesFromFile():
|
|
| 23 |
|
| 24 |
def PopulateThemesByPerson():
|
| 25 |
global themes, themes_by_person
|
| 26 |
-
print("*** themes:")
|
| 27 |
-
print (themes)
|
| 28 |
themes_by_person = {}
|
| 29 |
for theme in themes:
|
| 30 |
person = theme['person']
|
|
@@ -35,14 +34,35 @@ def PopulateThemesByPerson():
|
|
| 35 |
def PrintThemesByPerson():
|
| 36 |
print("PrintThemesByPerson")
|
| 37 |
global themes_by_person
|
| 38 |
-
print("Themes by person: ")
|
| 39 |
-
print (themes_by_person)
|
| 40 |
for person, person_themes in themes_by_person.items():
|
| 41 |
print(f"Themes associated with {person}:")
|
| 42 |
-
print("Person themes:", person_themes)
|
| 43 |
for theme in person_themes:
|
| 44 |
print(f"Theme: {theme}")
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
def PopulatePeopleByThemes():
|
| 47 |
global themes, people_by_theme
|
| 48 |
people_by_theme = {}
|
|
@@ -54,24 +74,25 @@ def PopulatePeopleByThemes():
|
|
| 54 |
def PrintPeopleByThemes():
|
| 55 |
print("PrintPeopleByThemes")
|
| 56 |
global people_by_theme
|
| 57 |
-
print ("-- people by theme --")
|
| 58 |
-
print (people_by_theme)
|
| 59 |
for theme, people in people_by_theme.items():
|
| 60 |
print(f"Theme: {theme}")
|
| 61 |
print("People:", people)
|
| 62 |
|
| 63 |
-
def
|
| 64 |
-
global themes
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
#
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
random_group = random.sample(people, group_size)
|
| 73 |
-
return random_group
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
def FindOverlappingTopics(people):
|
| 76 |
global themes_by_person
|
| 77 |
if not people:
|
|
@@ -80,6 +101,7 @@ def FindOverlappingTopics(people):
|
|
| 80 |
|
| 81 |
# Get the themes for the first person in the people set
|
| 82 |
first_person_themes = themes_by_person.get(next(iter(people)), set())
|
|
|
|
| 83 |
# Initialize common_topics with the themes of the first person
|
| 84 |
common_topics = set(first_person_themes)
|
| 85 |
|
|
@@ -94,39 +116,12 @@ def FindOverlappingTopics(people):
|
|
| 94 |
|
| 95 |
return common_topics
|
| 96 |
|
| 97 |
-
def CreatePersonToThemeMapping():
|
| 98 |
-
global themes, people_by_theme
|
| 99 |
-
people_by_theme = {}
|
| 100 |
-
|
| 101 |
-
# Iterate through the list of themes
|
| 102 |
-
for theme in themes:
|
| 103 |
-
person = theme['person']
|
| 104 |
-
postId = theme['postId']
|
| 105 |
-
theme_info = (theme['theme'], postId)
|
| 106 |
-
|
| 107 |
-
# Check if the person already exists in the dictionary
|
| 108 |
-
if person not in people_by_theme:
|
| 109 |
-
people_by_theme[person] = set()
|
| 110 |
-
people_by_theme[person].add(theme_info)
|
| 111 |
-
|
| 112 |
-
def CreateThemeToPersonMapping():
|
| 113 |
-
global people_by_theme, themes_by_person
|
| 114 |
-
themes_by_person = {}
|
| 115 |
-
print("Createthemetopersonmapping")
|
| 116 |
-
# Iterate through the dictionary to create themes with unique people
|
| 117 |
-
for person, person_themes in people_by_theme.items():
|
| 118 |
-
for theme_info in person_themes:
|
| 119 |
-
theme, _ = theme_info
|
| 120 |
-
if theme not in themes_by_person:
|
| 121 |
-
themes_by_person[theme] = set()
|
| 122 |
-
themes_by_person[theme].add(person)
|
| 123 |
-
|
| 124 |
def GetEnjoymentIndex(choice):
|
| 125 |
# Extract the enjoyment index from the choice
|
| 126 |
print("choice", choice)
|
| 127 |
try:
|
| 128 |
choice_data = choice.get("metadata", {}).get("completion", {})
|
| 129 |
-
enjoyment_index = choice_data.get("
|
| 130 |
return float(enjoyment_index) if enjoyment_index else 0.0
|
| 131 |
except (ValueError, TypeError):
|
| 132 |
print("Failed to extract enjoyment index.")
|
|
@@ -135,7 +130,7 @@ def GetEnjoymentIndex(choice):
|
|
| 135 |
def GenerateGameIdeas(themes_by_theme):
|
| 136 |
print("GenerateGameIdeas, themes_by_theme:", themes_by_theme)
|
| 137 |
# Filter themes with more than two people sharing it
|
| 138 |
-
eligible_themes = {theme: people for theme, people in themes_by_theme.items() if len(people) >
|
| 139 |
print('\n****eligible themes')
|
| 140 |
for theme,people in eligible_themes.items():
|
| 141 |
print(f"Theme: {theme}")
|
|
@@ -150,30 +145,34 @@ def GenerateGameIdeas(themes_by_theme):
|
|
| 150 |
chosen_theme = random.choice(list(eligible_themes.keys()))
|
| 151 |
print ("chosen_theme",chosen_theme)
|
| 152 |
# Prepare the prompt for GenAI
|
| 153 |
-
prompt = f"Provide your top
|
| 154 |
-
# Make the GenAI request
|
| 155 |
response = openai.Completion.create(
|
| 156 |
engine="text-davinci-003",
|
| 157 |
prompt=prompt,
|
| 158 |
-
max_tokens=
|
| 159 |
n=1,
|
| 160 |
-
stop=None,
|
| 161 |
temperature=0.3,
|
| 162 |
-
top_p=
|
| 163 |
-
frequency_penalty=0.0,
|
| 164 |
-
presence_penalty=0.0
|
| 165 |
)
|
| 166 |
# Process the response and extract the game ideas
|
| 167 |
game_ideas = []
|
| 168 |
-
for choice in response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
try:
|
| 170 |
-
|
| 171 |
-
game_ideas.append(
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
| 175 |
# Sort the game ideas by enjoyment index in descending order
|
| 176 |
-
sorted_game_ideas = sorted(game_ideas, key=lambda x: x.get("
|
| 177 |
|
| 178 |
if sorted_game_ideas:
|
| 179 |
with open(OUTPUT_GAME_IDEAS_DATAPATH, 'w') as file:
|
|
@@ -181,16 +180,24 @@ def GenerateGameIdeas(themes_by_theme):
|
|
| 181 |
return sorted_game_ideas
|
| 182 |
else:
|
| 183 |
print("No game idea found.")
|
| 184 |
-
return None
|
|
|
|
| 185 |
|
| 186 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
global themes
|
| 188 |
ReadThemesFromFile()
|
| 189 |
-
group=CreateRandomGroup(3)
|
| 190 |
-
print("group", group)
|
| 191 |
-
common_topics = FindOverlappingTopics(group)
|
| 192 |
-
print("common topics: ", common_topics)
|
| 193 |
-
|
| 194 |
PopulatePeopleByThemes()
|
| 195 |
CreatePersonToThemeMapping()
|
| 196 |
PrintPeopleByThemes()
|
|
@@ -199,10 +206,24 @@ def CreateGames():
|
|
| 199 |
CreateThemeToPersonMapping()
|
| 200 |
PrintThemesByPerson()
|
| 201 |
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
print("Generated Game Idea:")
|
| 206 |
print(game_ideas)
|
| 207 |
-
|
|
|
|
| 208 |
return None
|
|
|
|
| 14 |
themes = []
|
| 15 |
themes_by_person={}
|
| 16 |
people_by_theme = {}
|
| 17 |
+
players=[]
|
| 18 |
|
| 19 |
def ReadThemesFromFile():
|
| 20 |
global themes
|
|
|
|
| 24 |
|
| 25 |
def PopulateThemesByPerson():
|
| 26 |
global themes, themes_by_person
|
|
|
|
|
|
|
| 27 |
themes_by_person = {}
|
| 28 |
for theme in themes:
|
| 29 |
person = theme['person']
|
|
|
|
| 34 |
def PrintThemesByPerson():
|
| 35 |
print("PrintThemesByPerson")
|
| 36 |
global themes_by_person
|
|
|
|
|
|
|
| 37 |
for person, person_themes in themes_by_person.items():
|
| 38 |
print(f"Themes associated with {person}:")
|
| 39 |
+
print("Person themes:", person_themes)
|
| 40 |
for theme in person_themes:
|
| 41 |
print(f"Theme: {theme}")
|
| 42 |
|
| 43 |
+
def CreateThemeToPersonMapping():
|
| 44 |
+
global people_by_theme, themes_by_person
|
| 45 |
+
themes_by_person = {}
|
| 46 |
+
print("Createthemetopersonmapping")
|
| 47 |
+
# Iterate through the dictionary to create themes with unique people
|
| 48 |
+
for person, person_themes in people_by_theme.items():
|
| 49 |
+
for theme_info in person_themes:
|
| 50 |
+
theme, _ = theme_info
|
| 51 |
+
if theme not in themes_by_person:
|
| 52 |
+
themes_by_person[theme] = set()
|
| 53 |
+
themes_by_person[theme].add(person)
|
| 54 |
+
|
| 55 |
+
def CreateRandomGroup(group_size):
|
| 56 |
+
global themes
|
| 57 |
+
# Extract all unique people from the theme list
|
| 58 |
+
people = list(set(theme['person'] for theme in themes))
|
| 59 |
+
# Check if the group size is larger than the available people
|
| 60 |
+
if group_size > len(people):
|
| 61 |
+
group_size=len(people)
|
| 62 |
+
# Randomly select a group of people
|
| 63 |
+
random_group = random.sample(people, group_size)
|
| 64 |
+
return random_group
|
| 65 |
+
|
| 66 |
def PopulatePeopleByThemes():
|
| 67 |
global themes, people_by_theme
|
| 68 |
people_by_theme = {}
|
|
|
|
| 74 |
def PrintPeopleByThemes():
|
| 75 |
print("PrintPeopleByThemes")
|
| 76 |
global people_by_theme
|
|
|
|
|
|
|
| 77 |
for theme, people in people_by_theme.items():
|
| 78 |
print(f"Theme: {theme}")
|
| 79 |
print("People:", people)
|
| 80 |
|
| 81 |
+
def CreatePersonToThemeMapping():
|
| 82 |
+
global themes, people_by_theme
|
| 83 |
+
people_by_theme = {}
|
| 84 |
+
|
| 85 |
+
# Iterate through the list of themes
|
| 86 |
+
for theme in themes:
|
| 87 |
+
person = theme['person']
|
| 88 |
+
postId = theme['postId']
|
| 89 |
+
theme_info = (theme['theme'], postId)
|
|
|
|
|
|
|
| 90 |
|
| 91 |
+
# Check if the person already exists in the dictionary
|
| 92 |
+
if person not in people_by_theme:
|
| 93 |
+
people_by_theme[person] = set()
|
| 94 |
+
people_by_theme[person].add(theme_info)
|
| 95 |
+
|
| 96 |
def FindOverlappingTopics(people):
|
| 97 |
global themes_by_person
|
| 98 |
if not people:
|
|
|
|
| 101 |
|
| 102 |
# Get the themes for the first person in the people set
|
| 103 |
first_person_themes = themes_by_person.get(next(iter(people)), set())
|
| 104 |
+
|
| 105 |
# Initialize common_topics with the themes of the first person
|
| 106 |
common_topics = set(first_person_themes)
|
| 107 |
|
|
|
|
| 116 |
|
| 117 |
return common_topics
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
def GetEnjoymentIndex(choice):
|
| 120 |
# Extract the enjoyment index from the choice
|
| 121 |
print("choice", choice)
|
| 122 |
try:
|
| 123 |
choice_data = choice.get("metadata", {}).get("completion", {})
|
| 124 |
+
enjoyment_index = choice_data.get("EnjoymentIndex")
|
| 125 |
return float(enjoyment_index) if enjoyment_index else 0.0
|
| 126 |
except (ValueError, TypeError):
|
| 127 |
print("Failed to extract enjoyment index.")
|
|
|
|
| 130 |
def GenerateGameIdeas(themes_by_theme):
|
| 131 |
print("GenerateGameIdeas, themes_by_theme:", themes_by_theme)
|
| 132 |
# Filter themes with more than two people sharing it
|
| 133 |
+
eligible_themes = {theme: people for theme, people in themes_by_theme.items() if len(people) > 1}
|
| 134 |
print('\n****eligible themes')
|
| 135 |
for theme,people in eligible_themes.items():
|
| 136 |
print(f"Theme: {theme}")
|
|
|
|
| 145 |
chosen_theme = random.choice(list(eligible_themes.keys()))
|
| 146 |
print ("chosen_theme",chosen_theme)
|
| 147 |
# Prepare the prompt for GenAI
|
| 148 |
+
prompt = f"""Provide your top idea for a text-based game a group of based on their theme '{chosen_theme}'. For each idea, games should be fully playable via text using chat interface. Provide a rationale of why you chose that game, an enjoyment index. Keep your answers short. Answer in JSON, like this: {{"Name":"Name of game","Description":"Game description & rules","EnjoymentIndex":"Your guess as a probability from 0.0 to 1.0","Rationale":"Reasoning for game selection"}}""" # Make the GenAI request
|
|
|
|
| 149 |
response = openai.Completion.create(
|
| 150 |
engine="text-davinci-003",
|
| 151 |
prompt=prompt,
|
| 152 |
+
max_tokens=800,
|
| 153 |
n=1,
|
|
|
|
| 154 |
temperature=0.3,
|
| 155 |
+
top_p=.8
|
|
|
|
|
|
|
| 156 |
)
|
| 157 |
# Process the response and extract the game ideas
|
| 158 |
game_ideas = []
|
| 159 |
+
for choice in response["choices"]:
|
| 160 |
+
print("choice")
|
| 161 |
+
print (choice)
|
| 162 |
+
choiceText = choice["text"]
|
| 163 |
+
game_data = choiceText.strip('\n')
|
| 164 |
+
print("--after strip camge_data", game_data)
|
| 165 |
try:
|
| 166 |
+
game_data_dict = json.loads(game_data)
|
| 167 |
+
game_ideas.append(game_data_dict)
|
| 168 |
+
print("game_data", game_data_dict)
|
| 169 |
+
except json.JSONDecodeError:
|
| 170 |
+
print("Error decoding JSON. Skipping this entry.")
|
| 171 |
+
''' GenerateGameIdeas(themes_by_theme)'''
|
| 172 |
+
continue
|
| 173 |
+
|
| 174 |
# Sort the game ideas by enjoyment index in descending order
|
| 175 |
+
sorted_game_ideas = sorted(game_ideas, key=lambda x: x.get("EnjoymentIndex", 0.0), reverse=True)
|
| 176 |
|
| 177 |
if sorted_game_ideas:
|
| 178 |
with open(OUTPUT_GAME_IDEAS_DATAPATH, 'w') as file:
|
|
|
|
| 180 |
return sorted_game_ideas
|
| 181 |
else:
|
| 182 |
print("No game idea found.")
|
| 183 |
+
return None
|
| 184 |
+
|
| 185 |
|
| 186 |
+
def GetPlayers():
|
| 187 |
+
players = [] # Initialize an empty list
|
| 188 |
+
index = 0 # Initialize an index variable starting from 0
|
| 189 |
+
for theme in themes: # Assuming themes is a list of dictionaries
|
| 190 |
+
person = theme['person']
|
| 191 |
+
if person not in [t[0] for t in players]: # Check if the person is already in the list
|
| 192 |
+
players.append((person, index)) # Append a tuple (str, int)
|
| 193 |
+
index += 1 # Increment the index
|
| 194 |
+
print("players")
|
| 195 |
+
print(players)
|
| 196 |
+
return players
|
| 197 |
+
|
| 198 |
+
def LoadThemes():
|
| 199 |
global themes
|
| 200 |
ReadThemesFromFile()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
PopulatePeopleByThemes()
|
| 202 |
CreatePersonToThemeMapping()
|
| 203 |
PrintPeopleByThemes()
|
|
|
|
| 206 |
CreateThemeToPersonMapping()
|
| 207 |
PrintThemesByPerson()
|
| 208 |
|
| 209 |
+
def CreateGameForGroup(group):
|
| 210 |
+
print("\n\ngroup, ", group)
|
| 211 |
+
common_topics = FindOverlappingTopics(group)
|
| 212 |
+
print("common topics: ", common_topics)
|
| 213 |
+
print("****")
|
| 214 |
+
print("people by theme: ", people_by_theme)
|
| 215 |
+
print("****")
|
| 216 |
+
print("themes by person: ", themes_by_person)
|
| 217 |
+
game_ideas = GenerateGameIdeas(themes_by_person)
|
| 218 |
+
print("game ideas: ")
|
| 219 |
+
print(game_ideas)
|
| 220 |
+
''' if( game_ideas is None):
|
| 221 |
+
print("game_ideas is None, trying again")
|
| 222 |
+
CreateGameForGroup(players)'''
|
| 223 |
+
|
| 224 |
+
if len(game_ideas) >0:
|
| 225 |
print("Generated Game Idea:")
|
| 226 |
print(game_ideas)
|
| 227 |
+
gameDF=pd.DataFrame(game_ideas)
|
| 228 |
+
return gameDF
|
| 229 |
return None
|
create_games/data/game_ideas.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
[
|
| 2 |
{
|
| 3 |
-
"
|
| 4 |
-
"
|
| 5 |
-
"
|
|
|
|
| 6 |
}
|
| 7 |
]
|
|
|
|
| 1 |
[
|
| 2 |
{
|
| 3 |
+
"Name": "John's Adventure",
|
| 4 |
+
"Description": "John's Adventure is a text-based game in which the player takes on the role of John, a brave explorer. The goal of the game is to explore the world, discover new lands, and complete various quests. The player must use their wits and skills to overcome obstacles and progress through the game. The game features a variety of puzzles, enemies, and items to collect. The game also features an inventory system and a leveling system.",
|
| 5 |
+
"EnjoymentIndex": "0.8",
|
| 6 |
+
"Rationale": "John's Adventure is a classic text-based game that offers a great deal of exploration and puzzle-solving. It also features a variety of items to collect and enemies to defeat, which adds to the game's replayability. The inventory and leveling systems also add an extra layer of depth to the game, making it more enjoyable for players."
|
| 7 |
}
|
| 8 |
]
|
home_view/__pycache__/app_theme.cpython-311.pyc
ADDED
|
Binary file (2.58 kB). View file
|
|
|
home_view/__pycache__/ui_home.cpython-311.pyc
ADDED
|
Binary file (6.5 kB). View file
|
|
|
home_view/app_theme.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
from typing import Iterable
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from gradio.themes.soft import Soft
|
| 5 |
+
from gradio.themes.utils import colors, fonts, sizes
|
| 6 |
+
import time
|
| 7 |
+
|
| 8 |
+
class SoftBlue(Soft):
|
| 9 |
+
def __init__(
|
| 10 |
+
self,
|
| 11 |
+
*,
|
| 12 |
+
primary_hue: colors.Color | str = colors.cyan,
|
| 13 |
+
secondary_hue: colors.Color | str = colors.indigo,
|
| 14 |
+
neutral_hue: colors.Color | str = colors.sky,
|
| 15 |
+
spacing_size: sizes.Size | str = sizes.spacing_md,
|
| 16 |
+
radius_size: sizes.Size | str = sizes.radius_md,
|
| 17 |
+
text_size: sizes.Size | str = sizes.text_lg,
|
| 18 |
+
font: fonts.Font
|
| 19 |
+
| str
|
| 20 |
+
| Iterable[fonts.Font | str] = (
|
| 21 |
+
fonts.GoogleFont("Quicksand"),
|
| 22 |
+
"ui-sans-serif",
|
| 23 |
+
"sans-serif",
|
| 24 |
+
),
|
| 25 |
+
font_mono: fonts.Font
|
| 26 |
+
| str
|
| 27 |
+
| Iterable[fonts.Font | str] = (
|
| 28 |
+
fonts.GoogleFont("IBM Plex Mono"),
|
| 29 |
+
"ui-monospace",
|
| 30 |
+
"monospace",
|
| 31 |
+
),
|
| 32 |
+
):
|
| 33 |
+
super().__init__(
|
| 34 |
+
primary_hue=primary_hue,
|
| 35 |
+
secondary_hue=secondary_hue,
|
| 36 |
+
neutral_hue=neutral_hue,
|
| 37 |
+
spacing_size=spacing_size,
|
| 38 |
+
radius_size=radius_size,
|
| 39 |
+
text_size=text_size,
|
| 40 |
+
font=font,
|
| 41 |
+
font_mono=font_mono,
|
| 42 |
+
)
|
| 43 |
+
# html font style accepts a string heading or body and returns the style for that element, should follow styles in class with exception that heading is +2 pts and bold
|
| 44 |
+
def html_font_style(self, element: str) -> str:
|
| 45 |
+
if element == "heading":
|
| 46 |
+
return f"font-family: {self.font_mono}; font-size: {self.text_sm}; font-weight: bold;"
|
| 47 |
+
elif element == "body":
|
| 48 |
+
return f"font-family: {self.font_mono}; font-size: {self.text_sm};"
|
| 49 |
+
elif element == "mono":
|
| 50 |
+
return f"font-family: {self.font_mono}; font-size: {self.text_sm};"
|
| 51 |
+
else:
|
| 52 |
+
raise ValueError(
|
| 53 |
+
f"Element must be one of 'heading', 'body', or 'mono', not {element}"
|
| 54 |
+
)
|
| 55 |
+
|
home_view/art/buildPlay.svg
ADDED
|
|
home_view/ui_home.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from home_view.app_theme import SoftBlue
|
| 4 |
+
from sketch import sketch as sk
|
| 5 |
+
from slack_processing.slack_data_prep import FetchSlack, ProcessSlack, CreateEmbeddings
|
| 6 |
+
from create_games.create_games_slack import LoadThemes,GetPlayers,CreateGameForGroup
|
| 7 |
+
|
| 8 |
+
startDF=pd.DataFrame()
|
| 9 |
+
slackDF=pd.DataFrame()
|
| 10 |
+
embeddingsDF=pd.DataFrame()
|
| 11 |
+
gamesDF=pd.DataFrame()
|
| 12 |
+
playersValues=[]
|
| 13 |
+
selected= []
|
| 14 |
+
players=[]
|
| 15 |
+
|
| 16 |
+
def Init():
|
| 17 |
+
global startDF, slackDF, embeddingsDF, gamesDF,players,playersValues
|
| 18 |
+
startDF=FetchSlack()
|
| 19 |
+
slackDF=ProcessSlack()
|
| 20 |
+
embeddingsDF=CreateEmbeddings()
|
| 21 |
+
gamesDF=LoadThemes()
|
| 22 |
+
playersValues=GetPlayers()
|
| 23 |
+
playersCB.choices = playersValues
|
| 24 |
+
|
| 25 |
+
def SetSelected(playersCB):
|
| 26 |
+
global playersValues,selected,players
|
| 27 |
+
selected=[]
|
| 28 |
+
for check in playersCB:
|
| 29 |
+
selected.append(check)
|
| 30 |
+
for player_name, player_id in playersValues:
|
| 31 |
+
if player_id == check:
|
| 32 |
+
if player_name not in players:
|
| 33 |
+
players.append(player_name)
|
| 34 |
+
break
|
| 35 |
+
|
| 36 |
+
def PlayGame():
|
| 37 |
+
print("PlayGame:")
|
| 38 |
+
#ui.add_child(home)
|
| 39 |
+
return gr.update(visible=True)
|
| 40 |
+
|
| 41 |
+
def Predict(sketch):
|
| 42 |
+
confidences = sk.Predict(sketch)
|
| 43 |
+
return confidences
|
| 44 |
+
|
| 45 |
+
def CreateGame():
|
| 46 |
+
global players,gameTitle
|
| 47 |
+
game_ideas = CreateGameForGroup(players)
|
| 48 |
+
if not game_ideas.empty:
|
| 49 |
+
game_ideas_dict = game_ideas.to_dict('records')
|
| 50 |
+
return game_ideas, game_ideas_dict[0]['Description'],game_ideas_dict[0]['Name']
|
| 51 |
+
return None,"No game"
|
| 52 |
+
|
| 53 |
+
df1 =gr.Dataframe(type="pandas", value=startDF)
|
| 54 |
+
df2 =gr.Dataframe(type="pandas", value=slackDF)
|
| 55 |
+
df3 =gr.Dataframe(type="pandas", value=embeddingsDF)
|
| 56 |
+
df4 =gr.Dataframe(type="pandas", value=gamesDF)
|
| 57 |
+
|
| 58 |
+
with gr.Blocks() as ui:
|
| 59 |
+
with gr.Row():
|
| 60 |
+
logo=gr.Image(value="home_view/art/buildPlay.svg", width=200, height=200, show_download_button=False, container=False)
|
| 61 |
+
directions= gr.Label(value="Directions go here", show_label=False, container=False)
|
| 62 |
+
with gr.Column():
|
| 63 |
+
playersCB = gr.CheckboxGroup ([], label="Players", info="Pick some players for the game!" )
|
| 64 |
+
createBtn = gr.Button(value="Create Game", variant="primary")
|
| 65 |
+
gameTitle=gr.Markdown("Game Title", container=False)
|
| 66 |
+
desc=gr.TextArea(info="Game Description", interactive=False, show_label=False, container=False,
|
| 67 |
+
placeholder="Your game description will show here", lines=3)
|
| 68 |
+
playBtn = gr.Button(value="Let's Play", variant="primary")
|
| 69 |
+
with gr.Row(visible=False) as holder:
|
| 70 |
+
sketch=gr.Image(image_mode="L", source="canvas", width=600, height =600, invert_colors=True, interactive=True,
|
| 71 |
+
brush_radius=.5,type="numpy",label="Sketch", show_label=True, show_upload_button=False, show_download_button=False,
|
| 72 |
+
container=False, allow_draw=True, allow_magnify=True, allow_color_picker=True)
|
| 73 |
+
label=gr.Label()
|
| 74 |
+
sketch.change(Predict, inputs=[sketch], outputs=[label])
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
with gr.Blocks() as dfs:
|
| 78 |
+
startBtn=gr.Button(value="BuildPlay", variant="primary")
|
| 79 |
+
gr.TabbedInterface([df1,df2,df3,df4], ("Start", "Slack","Embeddings","Games"))
|
| 80 |
+
startBtn.click(Init, inputs=[], outputs=[df1, df2, df3, df4])
|
| 81 |
+
playersCB.change(SetSelected, inputs=[playersCB], outputs=[])
|
| 82 |
+
createBtn.click(CreateGame, inputs=[], outputs=[df4,desc,gameTitle])
|
| 83 |
+
playBtn.click(PlayGame, inputs=[], outputs=[holder])
|
| 84 |
+
combo=gr.TabbedInterface([ui,dfs], ("BuildPlay", "DataFrames"),theme=SoftBlue())
|
| 85 |
+
Init()
|
players/ui_players.py
ADDED
|
File without changes
|
sketch/__pycache__/sketch.cpython-311.pyc
ADDED
|
Binary file (3.5 kB). View file
|
|
|
sketch/__pycache__/ui_sketch.cpython-311.pyc
ADDED
|
Binary file (4.73 kB). View file
|
|
|
sketch/class_names.txt
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
airplane
|
| 2 |
+
alarm_clock
|
| 3 |
+
anvil
|
| 4 |
+
apple
|
| 5 |
+
axe
|
| 6 |
+
baseball
|
| 7 |
+
baseball_bat
|
| 8 |
+
basketball
|
| 9 |
+
beard
|
| 10 |
+
bed
|
| 11 |
+
bench
|
| 12 |
+
bicycle
|
| 13 |
+
bird
|
| 14 |
+
book
|
| 15 |
+
bread
|
| 16 |
+
bridge
|
| 17 |
+
broom
|
| 18 |
+
butterfly
|
| 19 |
+
camera
|
| 20 |
+
candle
|
| 21 |
+
car
|
| 22 |
+
cat
|
| 23 |
+
ceiling_fan
|
| 24 |
+
cell_phone
|
| 25 |
+
chair
|
| 26 |
+
circle
|
| 27 |
+
clock
|
| 28 |
+
cloud
|
| 29 |
+
coffee_cup
|
| 30 |
+
cookie
|
| 31 |
+
cup
|
| 32 |
+
diving_board
|
| 33 |
+
donut
|
| 34 |
+
door
|
| 35 |
+
drums
|
| 36 |
+
dumbbell
|
| 37 |
+
envelope
|
| 38 |
+
eye
|
| 39 |
+
eyeglasses
|
| 40 |
+
face
|
| 41 |
+
fan
|
| 42 |
+
flower
|
| 43 |
+
frying_pan
|
| 44 |
+
grapes
|
| 45 |
+
hammer
|
| 46 |
+
hat
|
| 47 |
+
headphones
|
| 48 |
+
helmet
|
| 49 |
+
hot_dog
|
| 50 |
+
ice_cream
|
| 51 |
+
key
|
| 52 |
+
knife
|
| 53 |
+
ladder
|
| 54 |
+
laptop
|
| 55 |
+
light_bulb
|
| 56 |
+
lightning
|
| 57 |
+
line
|
| 58 |
+
lollipop
|
| 59 |
+
microphone
|
| 60 |
+
moon
|
| 61 |
+
mountain
|
| 62 |
+
moustache
|
| 63 |
+
mushroom
|
| 64 |
+
pants
|
| 65 |
+
paper_clip
|
| 66 |
+
pencil
|
| 67 |
+
pillow
|
| 68 |
+
pizza
|
| 69 |
+
power_outlet
|
| 70 |
+
radio
|
| 71 |
+
rainbow
|
| 72 |
+
rifle
|
| 73 |
+
saw
|
| 74 |
+
scissors
|
| 75 |
+
screwdriver
|
| 76 |
+
shorts
|
| 77 |
+
shovel
|
| 78 |
+
smiley_face
|
| 79 |
+
snake
|
| 80 |
+
sock
|
| 81 |
+
spider
|
| 82 |
+
spoon
|
| 83 |
+
square
|
| 84 |
+
star
|
| 85 |
+
stop_sign
|
| 86 |
+
suitcase
|
| 87 |
+
sun
|
| 88 |
+
sword
|
| 89 |
+
syringe
|
| 90 |
+
t-shirt
|
| 91 |
+
table
|
| 92 |
+
tennis_racquet
|
| 93 |
+
tent
|
| 94 |
+
tooth
|
| 95 |
+
traffic_light
|
| 96 |
+
tree
|
| 97 |
+
triangle
|
| 98 |
+
umbrella
|
| 99 |
+
wheel
|
| 100 |
+
wristwatch
|
sketch/pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:effb6ea6f1593c09e8247944028ed9c309b5ff1cef82ba38b822bee2ca4d0f3c
|
| 3 |
+
size 1656903
|
sketch/sketch.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import numpy as np
|
| 4 |
+
from torch import nn
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
PATH="sketch/class_names.txt"
|
| 8 |
+
LABELS = Path(PATH).read_text().splitlines()
|
| 9 |
+
|
| 10 |
+
model = nn.Sequential(
|
| 11 |
+
nn.Conv2d(1, 32, 3, padding='same'),
|
| 12 |
+
nn.ReLU(),
|
| 13 |
+
nn.MaxPool2d(2),
|
| 14 |
+
nn.Conv2d(32, 64, 3, padding='same'),
|
| 15 |
+
nn.ReLU(),
|
| 16 |
+
nn.MaxPool2d(2),
|
| 17 |
+
nn.Conv2d(64, 128, 3, padding='same'),
|
| 18 |
+
nn.ReLU(),
|
| 19 |
+
nn.MaxPool2d(2),
|
| 20 |
+
nn.Flatten(),
|
| 21 |
+
nn.Linear(1152, 256),
|
| 22 |
+
nn.ReLU(),
|
| 23 |
+
nn.Linear(256, len(LABELS)),
|
| 24 |
+
)
|
| 25 |
+
state_dict = torch.load('sketch/pytorch_model.bin', map_location='cpu')
|
| 26 |
+
model.load_state_dict(state_dict, strict=False)
|
| 27 |
+
model.eval()
|
| 28 |
+
|
| 29 |
+
def Predict(img):
|
| 30 |
+
# Convert to grayscale if the image is RGB
|
| 31 |
+
if img is not None and img.any():
|
| 32 |
+
if img.shape[-1] == 3:
|
| 33 |
+
img = np.mean(img, axis=-1)
|
| 34 |
+
# Convert the NumPy array to a PIL image
|
| 35 |
+
img_pil = Image.fromarray(img.astype('uint8'))
|
| 36 |
+
# Resize the image
|
| 37 |
+
img_resized = img_pil.resize((28, 28), Image.ANTIALIAS)
|
| 38 |
+
# Convert the PIL image back to a NumPy array
|
| 39 |
+
img_np = np.array(img_resized)
|
| 40 |
+
# Convert to tensor and normalize
|
| 41 |
+
x = torch.tensor(img_np, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.0
|
| 42 |
+
# Model prediction
|
| 43 |
+
with torch.no_grad():
|
| 44 |
+
out = model(x)
|
| 45 |
+
probabilities = torch.nn.functional.softmax(out[0], dim=0)
|
| 46 |
+
values, indices = torch.topk(probabilities, 5)
|
| 47 |
+
confidences = {LABELS[i]: v.item() for i, v in zip(indices, values)}
|
| 48 |
+
return confidences
|
| 49 |
+
|
slack_processing/__pycache__/theme.cpython-311.pyc
CHANGED
|
Binary files a/slack_processing/__pycache__/theme.cpython-311.pyc and b/slack_processing/__pycache__/theme.cpython-311.pyc differ
|
|
|
ui_holder.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from openai.embeddings_utils import get_embedding, cosine_similarity
|
| 4 |
+
from slack_processing.slack_data_prep import FetchSlack, ProcessSlack, CreateEmbeddings
|
| 5 |
+
from create_games.create_games_slack import CreateGames
|
| 6 |
+
|
| 7 |
+
def InitDF():
|
| 8 |
+
global imageDF
|
| 9 |
+
imageDF=pd.DataFrame({"role": [""], "content": [""] })
|
| 10 |
+
|
| 11 |
+
def UpdateArtSetting(setting):
|
| 12 |
+
global settingOptions
|
| 13 |
+
settingOptions.value=setting
|
| 14 |
+
|
| 15 |
+
def UpdateArtStyle(art):
|
| 16 |
+
global artOptions
|
| 17 |
+
artOptions.value=art
|
| 18 |
+
|
| 19 |
+
def Generate(imageDescription):
|
| 20 |
+
global artOptions, settingOptions
|
| 21 |
+
return image_generation.GenerateImages(imageDescription, artOptions, settingOptions)
|
| 22 |
+
|
| 23 |
+
def FetchSlackJSON():
|
| 24 |
+
result=FetchSlack()
|
| 25 |
+
print("slack fetch")
|
| 26 |
+
print (result)
|
| 27 |
+
return result
|
| 28 |
+
|
| 29 |
+
def InitProcess():
|
| 30 |
+
result=ProcessSlack()
|
| 31 |
+
print("slack processed")
|
| 32 |
+
print (result)
|
| 33 |
+
return result
|
| 34 |
+
|
| 35 |
+
def FetchEmbeddings():
|
| 36 |
+
result = CreateEmbeddings()
|
| 37 |
+
print("fetch embeddings")
|
| 38 |
+
print(result)
|
| 39 |
+
return result
|
| 40 |
+
|
| 41 |
+
def FetchGames():
|
| 42 |
+
result = CreateGames()
|
| 43 |
+
print("result")
|
| 44 |
+
print(result)
|
| 45 |
+
return result
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
with gr.Blocks() as ui1:
|
| 49 |
+
with gr.Row():
|
| 50 |
+
b1 = gr.Button("Fetch Slack JSON")
|
| 51 |
+
with gr.Row():
|
| 52 |
+
with gr.Column(scale=1, min_width=600):
|
| 53 |
+
df1 =gr.Dataframe(type="pandas")
|
| 54 |
+
b1.click(FetchSlackJSON,outputs=df1)
|
| 55 |
+
|
| 56 |
+
with gr.Blocks() as ui2:
|
| 57 |
+
with gr.Row():
|
| 58 |
+
b2 = gr.Button("Process & Tag Slack Data")
|
| 59 |
+
with gr.Row():
|
| 60 |
+
with gr.Column(scale=1, min_width=600):
|
| 61 |
+
df2 =gr.Dataframe(type="pandas")
|
| 62 |
+
b2.click(ProcessSlack,outputs=df2)
|
| 63 |
+
|
| 64 |
+
with gr.Blocks() as ui3:
|
| 65 |
+
with gr.Row():
|
| 66 |
+
b3 = gr.Button("Create Embeddings")
|
| 67 |
+
with gr.Row():
|
| 68 |
+
with gr.Column(scale=1, min_width=600):
|
| 69 |
+
df3 =gr.Dataframe(type="pandas")
|
| 70 |
+
b3.click(FetchEmbeddings,outputs=df3)
|
| 71 |
+
|
| 72 |
+
with gr.Blocks() as ui4:
|
| 73 |
+
with gr.Row():
|
| 74 |
+
b4 = gr.Button("Find Games")
|
| 75 |
+
with gr.Row():
|
| 76 |
+
with gr.Column(scale=1, min_width=600):
|
| 77 |
+
df4 =gr.Dataframe(type="pandas")
|
| 78 |
+
b4.click(FetchGames,outputs=df4)
|
| 79 |
+
|
| 80 |
+
demo = gr.TabbedInterface([ui1,ui2,ui3,ui4], ("Fetch Slack", "Process & Tag", "Create Embeddings", "Find Games"))
|