Spaces:
Sleeping
Sleeping
drakosfire
commited on
Commit
•
75a5574
1
Parent(s):
2e63ce0
Modified pet-generator to use ChatGPT 4o and Fal.ai
Browse files- README.md +13 -14
- app.py +106 -117
- card_generator.py +28 -35
- img2img.py +82 -24
- item_dict_gen.py +270 -346
- user_input.py +3 -17
- utilities.py +4 -0
README.md
CHANGED
@@ -4,34 +4,33 @@ emoji: 🃏
|
|
4 |
colorFrom: yellow
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
# Drakosfire's
|
13 |
|
14 |
-
|
15 |
|
16 |
## Overview
|
17 |
|
18 |
-
This generator leverages an API call to
|
19 |
|
20 |
## Key Features
|
21 |
|
22 |
-
- **Custom Fine-Tuning**: The backbone of this generator is a fine-tuned
|
23 |
|
24 |
-
- **Consistent Card Design**: To ensure each card maintains a uniform appearance, a LoRA (
|
25 |
|
26 |
## How It Works
|
27 |
|
28 |
-
1. Your intitial text along with the prompt is sent to
|
29 |
-
2. This
|
30 |
-
3. The final text field is the
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
3. **Result**: The final product is a beautifully crafted D&D item card, ready for use in your gaming sessions.
|
35 |
|
36 |
## Example Cards
|
37 |
|
@@ -44,4 +43,4 @@ Below are a few examples of the item cards I've generated:
|
|
44 |
![Ridiculously Cute Kitten](https://cdn-lfs-us-1.huggingface.co/repos/cb/b4/cbb436e53a2021c9535cec40c6360a89a1d6f5e42bc18d88bbd2da335dde82bd/863ef9235c94e60fd7176db237e3939f67c6a22bce3015712ff2336a49065f83?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27Ridiculouslycutekitten.png%3B+filename%3D%22Ridiculouslycutekitten.png%22%3B&response-content-type=image%2Fpng&Expires=1714445494&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcxNDQ0NTQ5NH19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmh1Z2dpbmdmYWNlLmNvL3JlcG9zL2NiL2I0L2NiYjQzNmU1M2EyMDIxYzk1MzVjZWM0MGM2MzYwYTg5YTFkNmY1ZTQyYmMxOGQ4OGJiZDJkYTMzNWRkZTgyYmQvODYzZWY5MjM1Yzk0ZTYwZmQ3MTc2ZGIyMzdlMzkzOWY2N2M2YTIyYmNlMzAxNTcxMmZmMjMzNmE0OTA2NWY4Mz9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSomcmVzcG9uc2UtY29udGVudC10eXBlPSoifV19&Signature=Awm-rIF7be1FRdKIU2zR-cxZa3KtR7FcYmPgVTqfaa2oMKZhU2vkG3lLHXimFvVuXbiv8Rd4ZnijffjWyEBWs6FV5L2JFQ2jG%7EDhlBIdWj-6skbvYwgxsbAfDclBbBv3zyZs%7EDK0rzEqvIDdd8Avud9NtXvyMpSFZTx2zUzGMp1saHLaYH2uU91z7zWHLhnL0XVW1JvY6RbaNx0Ydtx42r1IWqVpLqpB6yGoeIU2PBQCpNiuY61zwjOCg2iMM3OuXJ56eULFXtnrbJbqDSZnlIibELCZ%7EJQCozeVSvi-OK6HOkD7W7tPSnbfx2f9GIY1FkmzoXh-K7cFNL-CxYnCjw__&Key-Pair-Id=KCD77M1F0VK2B)
|
45 |
|
46 |
|
47 |
-
|
|
|
4 |
colorFrom: yellow
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.44.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
+
# Drakosfire's Cyber Pet Card Generator
|
13 |
|
14 |
+
This is a tool built to generate custom cyborg pets for an unnanounced creative project.
|
15 |
|
16 |
## Overview
|
17 |
|
18 |
+
This generator leverages an API call to FAL.ai to generate images with a custom LoRA trained off of my card dataset as well as OpenAI's GPT-4o to generate text and image prompts for the images.
|
19 |
|
20 |
## Key Features
|
21 |
|
22 |
+
- **Custom Fine-Tuning**: The backbone of this generator is a fine-tuned Flux.1 model, specifically optimized for generating high-quality, pet images on a unique card border that is flavored by your imagination.
|
23 |
|
24 |
+
- **Consistent Card Design**: To ensure each card maintains a uniform appearance, a LoRA (Low-Rank Adaptation) technique was used. This involved training the model with a hand-crafted dataset of card border images, enabling the system to generate new cards with consistent text and image spaces where the generated text and images can be elegantly integrated.
|
25 |
|
26 |
## How It Works
|
27 |
|
28 |
+
1. Your intitial text along with the prompt is sent to OpenAI's GPT-4o to generate a JSON.
|
29 |
+
2. This JSON will be parsed into textboxes to review and edit.
|
30 |
+
3. The final text field is the image prompt, these generate like one sentence stories describing the scene of your pet.
|
31 |
+
4. **Image and Text Generation**: Now generate 4 blank cards in about 15 seconds.
|
32 |
+
5. Finally, click the add text button to add text to your favorite template.
|
33 |
+
3. **Result**: The final product is a beautifully crafted collectible pet card.
|
|
|
34 |
|
35 |
## Example Cards
|
36 |
|
|
|
43 |
![Ridiculously Cute Kitten](https://cdn-lfs-us-1.huggingface.co/repos/cb/b4/cbb436e53a2021c9535cec40c6360a89a1d6f5e42bc18d88bbd2da335dde82bd/863ef9235c94e60fd7176db237e3939f67c6a22bce3015712ff2336a49065f83?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27Ridiculouslycutekitten.png%3B+filename%3D%22Ridiculouslycutekitten.png%22%3B&response-content-type=image%2Fpng&Expires=1714445494&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcxNDQ0NTQ5NH19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmh1Z2dpbmdmYWNlLmNvL3JlcG9zL2NiL2I0L2NiYjQzNmU1M2EyMDIxYzk1MzVjZWM0MGM2MzYwYTg5YTFkNmY1ZTQyYmMxOGQ4OGJiZDJkYTMzNWRkZTgyYmQvODYzZWY5MjM1Yzk0ZTYwZmQ3MTc2ZGIyMzdlMzkzOWY2N2M2YTIyYmNlMzAxNTcxMmZmMjMzNmE0OTA2NWY4Mz9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSomcmVzcG9uc2UtY29udGVudC10eXBlPSoifV19&Signature=Awm-rIF7be1FRdKIU2zR-cxZa3KtR7FcYmPgVTqfaa2oMKZhU2vkG3lLHXimFvVuXbiv8Rd4ZnijffjWyEBWs6FV5L2JFQ2jG%7EDhlBIdWj-6skbvYwgxsbAfDclBbBv3zyZs%7EDK0rzEqvIDdd8Avud9NtXvyMpSFZTx2zUzGMp1saHLaYH2uU91z7zWHLhnL0XVW1JvY6RbaNx0Ydtx42r1IWqVpLqpB6yGoeIU2PBQCpNiuY61zwjOCg2iMM3OuXJ56eULFXtnrbJbqDSZnlIibELCZ%7EJQCozeVSvi-OK6HOkD7W7tPSnbfx2f9GIY1FkmzoXh-K7cFNL-CxYnCjw__&Key-Pair-Id=KCD77M1F0VK2B)
|
44 |
|
45 |
|
46 |
+
|
app.py
CHANGED
@@ -13,28 +13,28 @@ with gr.Blocks() as demo:
|
|
13 |
# Functions and State Variables
|
14 |
# Build functions W/in the Gradio format, because it only allows modification within it's context
|
15 |
# Define inputs to match what is called on click, and output of the function as a list that matches the list of outputs
|
16 |
-
textbox_default_dict = {'Name':'',
|
17 |
-
'
|
18 |
-
'
|
19 |
-
'
|
20 |
-
'
|
21 |
-
'
|
22 |
-
'
|
23 |
-
'
|
24 |
-
'
|
25 |
-
'
|
26 |
}
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
|
39 |
selected_border_image = gr.State('./card_templates/Moonstone Border.png')
|
40 |
num_image_to_generate = gr.State(4)
|
@@ -53,37 +53,27 @@ with gr.Blocks() as demo:
|
|
53 |
def generate_text_update_textboxes(user_input):
|
54 |
|
55 |
llm_output=useri.call_llm(user_input)
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
return [item_name, item_name,
|
78 |
-
item_type, item_type,
|
79 |
-
item_rarity, item_rarity,
|
80 |
-
item_value, item_value,
|
81 |
-
item_properties, item_properties,
|
82 |
-
item_damage, item_damage,
|
83 |
-
item_weight, item_weight,
|
84 |
-
item_description, item_description,
|
85 |
-
item_quote, item_quote,
|
86 |
-
sd_prompt, sd_prompt]
|
87 |
|
88 |
# Called on user selecting an image from the gallery, outputs the path of the image
|
89 |
def assign_img_path(evt: gr.SelectData):
|
@@ -102,18 +92,9 @@ with gr.Blocks() as demo:
|
|
102 |
# Called when pressing button to generate image, updates gallery by returning the list of image URLs
|
103 |
def generate_image_update_gallery(num_img, sd_prompt,item_name, built_template):
|
104 |
delete_temp_images()
|
|
|
105 |
print(f"sd_prompt is a {type(sd_prompt)}")
|
106 |
-
image_list =
|
107 |
-
|
108 |
-
|
109 |
-
for x in range(num_img):
|
110 |
-
preview = img2img.preview_and_generate_image(x,sd_prompt, built_template, item_name)
|
111 |
-
image_list.append(preview)
|
112 |
-
yield image_list
|
113 |
-
|
114 |
-
del preview
|
115 |
-
|
116 |
-
#generated_image_list = img2img.generate_image(num_img,sd_prompt,item_name,selected_border)
|
117 |
return image_list
|
118 |
|
119 |
def build_template(selected_border, selected_seed_image):
|
@@ -201,10 +182,10 @@ with gr.Blocks() as demo:
|
|
201 |
build_card_template_button.click(build_template, inputs = [selected_border_image, selected_seed_image], outputs = [built_template_gallery, built_template])
|
202 |
|
203 |
gr.HTML(""" <div id="inner"> <header>
|
204 |
-
<h2><b>Second:</b> Generate
|
205 |
</div>""")
|
206 |
gr.HTML(""" <div id="inner"> <header>
|
207 |
-
<h3>1. Use a
|
208 |
</div>""")
|
209 |
with gr.Row():
|
210 |
user_input = gr.Textbox(label = 'Item', lines =1, placeholder= "Flaming Magical Sword", elem_id= "Item", scale =4)
|
@@ -214,30 +195,43 @@ with gr.Blocks() as demo:
|
|
214 |
<h3> 2. Review and Edit the text</h3>
|
215 |
</div>""")
|
216 |
with gr.Row():
|
217 |
-
|
218 |
-
# Build text boxes for the broken up item dictionary values
|
219 |
-
|
220 |
# Build text boxes for the broken up item dictionary values
|
221 |
with gr.Column(scale = 1):
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
|
227 |
-
|
228 |
with gr.Column(scale = 1):
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
|
236 |
gr.HTML(""" <div id="inner"> <header>
|
237 |
<h3> 3. This text will be used to generate the card's image.</h3>
|
238 |
</div>""")
|
239 |
-
|
240 |
-
|
241 |
gr.HTML(""" <div id="inner"> <header>
|
242 |
<h2> <b>Third:</b> Click 'Generate Cards' to generate 4 cards to choose from. \n First image from a cold boot takes about 2 minutes. \n After that it's 10 seconds per image. </h2>
|
243 |
</div>""")
|
@@ -261,51 +255,46 @@ with gr.Blocks() as demo:
|
|
261 |
elem_id = "Generated Cards Gallery",
|
262 |
allow_preview=True
|
263 |
)
|
264 |
-
|
265 |
-
|
266 |
|
267 |
-
card_gen_button.click(fn = generate_image_update_gallery,
|
268 |
-
inputs =[num_image_to_generate,item_sd_prompt_output,item_name_output,
|
269 |
-
built_template_gallery], outputs= generate_gallery,
|
270 |
-
show_progress=True)
|
271 |
generate_gallery.select(assign_img_path, outputs = selected_generated_image)
|
272 |
|
273 |
# Button logice calls function when button object is pressed, passing inputs and passing output to components
|
274 |
llm_output = item_text_generate.click(generate_text_update_textboxes,
|
275 |
inputs = [user_input],
|
276 |
-
outputs= [
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
|
297 |
|
298 |
generate_final_item_card.click(card.render_text_on_card, inputs = [selected_generated_image,
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
],
|
309 |
outputs = generate_gallery )
|
310 |
base_dir = os.path.dirname(os.path.abspath(__file__)) # Gets the directory where the script is located
|
311 |
print(f"Base Directory :",base_dir)
|
|
|
13 |
# Functions and State Variables
|
14 |
# Build functions W/in the Gradio format, because it only allows modification within it's context
|
15 |
# Define inputs to match what is called on click, and output of the function as a list that matches the list of outputs
|
16 |
+
textbox_default_dict = {'Name':'',
|
17 |
+
'Pet Species': '',
|
18 |
+
'Breed':'',
|
19 |
+
'Fur':'',
|
20 |
+
'Intelligence Level':'',
|
21 |
+
'Affection Level':'',
|
22 |
+
'Energy Level':'',
|
23 |
+
'Noise Level':'',
|
24 |
+
'Play Level':'',
|
25 |
+
'image Prompt':''
|
26 |
}
|
27 |
+
# Text states
|
28 |
+
pet_name_state = gr.State()
|
29 |
+
pet_species_state = gr.State()
|
30 |
+
pet_breed_state = gr.State()
|
31 |
+
pet_fur_state = gr.State()
|
32 |
+
pet_intelligence_level_state = gr.State()
|
33 |
+
pet_affection_level_state = gr.State()
|
34 |
+
pet_energy_level_state = gr.State()
|
35 |
+
pet_noise_level_state = gr.State()
|
36 |
+
pet_play_level_state = gr.State()
|
37 |
+
image_prompt_var = gr.State('')
|
38 |
|
39 |
selected_border_image = gr.State('./card_templates/Moonstone Border.png')
|
40 |
num_image_to_generate = gr.State(4)
|
|
|
53 |
def generate_text_update_textboxes(user_input):
|
54 |
|
55 |
llm_output=useri.call_llm(user_input)
|
56 |
+
pet_key = list(llm_output.keys())
|
57 |
+
pet_name = llm_output[pet_key[0]]['Name']
|
58 |
+
pet_species = llm_output[pet_key[0]]['Pet Species']
|
59 |
+
pet_breed = llm_output[pet_key[0]]['Breed']
|
60 |
+
pet_fur = llm_output[pet_key[0]]['Fur']
|
61 |
+
pet_intelligence_level = llm_output[pet_key[0]]['Intelligence Level']
|
62 |
+
pet_affection_level = llm_output[pet_key[0]]['Affection Level']
|
63 |
+
pet_energy_level = llm_output[pet_key[0]]['Energy Level']
|
64 |
+
pet_noise_level = llm_output[pet_key[0]]['Noise Level']
|
65 |
+
pet_play_level = llm_output[pet_key[0]]['Play Level']
|
66 |
+
image_prompt = llm_output[pet_key[0]]['Image Prompt']
|
67 |
+
return [pet_name, pet_name,
|
68 |
+
pet_species, pet_species,
|
69 |
+
pet_breed, pet_breed,
|
70 |
+
pet_fur, pet_fur,
|
71 |
+
pet_intelligence_level, pet_intelligence_level,
|
72 |
+
pet_affection_level, pet_affection_level,
|
73 |
+
pet_energy_level, pet_energy_level,
|
74 |
+
pet_noise_level, pet_noise_level,
|
75 |
+
pet_play_level, pet_play_level,
|
76 |
+
image_prompt, image_prompt]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
# Called on user selecting an image from the gallery, outputs the path of the image
|
79 |
def assign_img_path(evt: gr.SelectData):
|
|
|
92 |
# Called when pressing button to generate image, updates gallery by returning the list of image URLs
|
93 |
def generate_image_update_gallery(num_img, sd_prompt,item_name, built_template):
|
94 |
delete_temp_images()
|
95 |
+
print(f"num_img is a {type(num_img)}")
|
96 |
print(f"sd_prompt is a {type(sd_prompt)}")
|
97 |
+
image_list = img2img.preview_and_generate_image(4,sd_prompt, built_template)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
return image_list
|
99 |
|
100 |
def build_template(selected_border, selected_seed_image):
|
|
|
182 |
build_card_template_button.click(build_template, inputs = [selected_border_image, selected_seed_image], outputs = [built_template_gallery, built_template])
|
183 |
|
184 |
gr.HTML(""" <div id="inner"> <header>
|
185 |
+
<h2><b>Second:</b> Generate Pet Text </h2>
|
186 |
</div>""")
|
187 |
gr.HTML(""" <div id="inner"> <header>
|
188 |
+
<h3>1. Use a name, a breed, some coloring and the animal type, Ex: 'Hermione the Stormy Grey English Shorthair Cat' then click 'Generate Text' </h3>
|
189 |
</div>""")
|
190 |
with gr.Row():
|
191 |
user_input = gr.Textbox(label = 'Item', lines =1, placeholder= "Flaming Magical Sword", elem_id= "Item", scale =4)
|
|
|
195 |
<h3> 2. Review and Edit the text</h3>
|
196 |
</div>""")
|
197 |
with gr.Row():
|
|
|
|
|
|
|
198 |
# Build text boxes for the broken up item dictionary values
|
199 |
with gr.Column(scale = 1):
|
200 |
+
pet_name_output = gr.Textbox(value = set_textbox_defaults(
|
201 |
+
textbox_default_dict, 'Name'),label = 'Name', lines = 1, interactive=True, elem_id='Pet Name')
|
202 |
+
|
203 |
+
pet_species_output = gr.Textbox(value = set_textbox_defaults(
|
204 |
+
textbox_default_dict, 'Pet Species'),label = 'Type', lines = 1, interactive=True, elem_id='Pet Species')
|
205 |
+
|
206 |
+
pet_breed_output = gr.Textbox(value = set_textbox_defaults(
|
207 |
+
textbox_default_dict, 'Breed'),label = 'Breed : [Common, Uncommon, Rare, Very Rare, Legendary]',
|
208 |
+
lines = 1, interactive=True, elem_id='Pet Breed')
|
209 |
+
|
210 |
+
pet_fur_output = gr.Textbox(value = set_textbox_defaults(
|
211 |
+
textbox_default_dict, 'Fur'),label = 'Fur Quality', lines = 1, interactive=True, elem_id='Pet Fur')
|
212 |
|
213 |
+
# Pass the user input and border template to the generator
|
214 |
with gr.Column(scale = 1):
|
215 |
+
pet_affection_level_output = gr.Textbox(value = set_textbox_defaults(
|
216 |
+
textbox_default_dict, 'Affection Level'),label = 'Affection Level', lines = 1, interactive=True, elem_id='Affection Level')
|
217 |
+
|
218 |
+
pet_energy_level_output = gr.Textbox(value = set_textbox_defaults(
|
219 |
+
textbox_default_dict, 'Energy Level'),label = 'Energy Level', lines = 1, interactive=True, elem_id='Energy Level')
|
220 |
+
|
221 |
+
pet_noise_level_output = gr.Textbox(value = set_textbox_defaults(
|
222 |
+
textbox_default_dict, 'Noise Level'),label = 'Noise Level', lines = 1, interactive=True, elem_id='Noise Level')
|
223 |
+
|
224 |
+
pet_play_level_output = gr.Textbox(value = set_textbox_defaults(
|
225 |
+
textbox_default_dict, 'Play Level'),label = 'Play Level', lines = 1, interactive=True, elem_id='Play Level')
|
226 |
+
|
227 |
+
pet_intelligence_level_output = gr.Textbox(value = set_textbox_defaults(
|
228 |
+
textbox_default_dict, 'Intelligence Level'),label = 'Intelligence Level',
|
229 |
+
lines = 1, interactive=True, elem_id='Intelligence Level')
|
230 |
|
231 |
gr.HTML(""" <div id="inner"> <header>
|
232 |
<h3> 3. This text will be used to generate the card's image.</h3>
|
233 |
</div>""")
|
234 |
+
image_prompt_output = gr.Textbox(label = 'Putting words or phrases in parenthesis adds weight. Example: (Flaming Magical :1.0) Sword.', value = set_textbox_defaults(textbox_default_dict, 'image Prompt'), lines = 1, interactive=True, elem_id='image Prompt')
|
|
|
235 |
gr.HTML(""" <div id="inner"> <header>
|
236 |
<h2> <b>Third:</b> Click 'Generate Cards' to generate 4 cards to choose from. \n First image from a cold boot takes about 2 minutes. \n After that it's 10 seconds per image. </h2>
|
237 |
</div>""")
|
|
|
255 |
elem_id = "Generated Cards Gallery",
|
256 |
allow_preview=True
|
257 |
)
|
|
|
|
|
258 |
|
259 |
+
card_gen_button.click(fn = generate_image_update_gallery, inputs =[num_image_to_generate,image_prompt_output,pet_name_output,built_template], outputs= generate_gallery)
|
|
|
|
|
|
|
260 |
generate_gallery.select(assign_img_path, outputs = selected_generated_image)
|
261 |
|
262 |
# Button logice calls function when button object is pressed, passing inputs and passing output to components
|
263 |
llm_output = item_text_generate.click(generate_text_update_textboxes,
|
264 |
inputs = [user_input],
|
265 |
+
outputs= [pet_name_state,
|
266 |
+
pet_name_output,
|
267 |
+
pet_species_state,
|
268 |
+
pet_species_output,
|
269 |
+
pet_breed_state,
|
270 |
+
pet_breed_output,
|
271 |
+
pet_fur_state,
|
272 |
+
pet_fur_output,
|
273 |
+
pet_intelligence_level_state,
|
274 |
+
pet_intelligence_level_output,
|
275 |
+
pet_affection_level_state,
|
276 |
+
pet_affection_level_output,
|
277 |
+
pet_energy_level_state,
|
278 |
+
pet_energy_level_output,
|
279 |
+
pet_noise_level_state,
|
280 |
+
pet_noise_level_output,
|
281 |
+
pet_play_level_state,
|
282 |
+
pet_play_level_output,
|
283 |
+
image_prompt_var,
|
284 |
+
image_prompt_output])
|
285 |
|
286 |
|
287 |
generate_final_item_card.click(card.render_text_on_card, inputs = [selected_generated_image,
|
288 |
+
pet_name_output,
|
289 |
+
pet_species_output,
|
290 |
+
pet_breed_output,
|
291 |
+
pet_fur_output,
|
292 |
+
pet_intelligence_level_output,
|
293 |
+
pet_affection_level_output,
|
294 |
+
pet_energy_level_output,
|
295 |
+
pet_noise_level_output,
|
296 |
+
pet_play_level_output
|
297 |
+
],
|
298 |
outputs = generate_gallery )
|
299 |
base_dir = os.path.dirname(os.path.abspath(__file__)) # Gets the directory where the script is located
|
300 |
print(f"Base Directory :",base_dir)
|
card_generator.py
CHANGED
@@ -3,6 +3,7 @@ from PIL import Image, ImageFilter
|
|
3 |
import utilities as u
|
4 |
import ast
|
5 |
from urllib.request import urlopen
|
|
|
6 |
|
7 |
def save_image(image,item_key):
|
8 |
image.save(f"{item_key['Name']}.png")
|
@@ -12,15 +13,15 @@ def save_image(image,item_key):
|
|
12 |
#shop_inventory = inv.inventory
|
13 |
#purchased_item_key = shop_inventory['Shortsword']
|
14 |
#border_path = './card_templates/Shining Sunset Border.png'
|
15 |
-
base_path = "https://media.githubusercontent.com/media/Drakosfire/CardGenerator/
|
16 |
-
value_overlay_path = f"{base_path}Value_box_transparent.png"
|
17 |
test_item = {'Name': 'Pustulent Raspberry', 'Type': 'Fruit', 'Value': '1 cp', 'Properties': ['Unusual Appearance', 'Rare Taste'], 'Weight': '0.2 lb', 'Description': 'This small fruit has a pustulent appearance, with bumps and irregular shapes covering its surface. Its vibrant colors and strange texture make it an oddity among other fruits.', 'Quote': 'A fruit that defies expectations, as sweet and sour as life itself.', 'SD Prompt': 'A small fruit with vibrant colors and irregular shapes, bumps covering its surface.'}
|
18 |
-
sticker_path_dictionary = {'Default':
|
19 |
-
'Common':
|
20 |
-
'Uncommon':
|
21 |
-
'Rare':
|
22 |
-
'Very Rare':
|
23 |
-
'Legendary':
|
24 |
|
25 |
|
26 |
# Function that takes in an image url and a dictionary and uses the values to print onto a card.
|
@@ -49,20 +50,19 @@ def paste_image_and_resize(base_image,sticker_path, x_position, y_position,img_w
|
|
49 |
# Paste the resized image onto the base image
|
50 |
base_image.paste(image_to_paste_resized, paste_position, image_to_paste_resized)
|
51 |
|
52 |
-
def render_text_on_card(image_path,
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
# Card Properties
|
62 |
image_list = []
|
63 |
-
|
64 |
-
|
65 |
-
output_image_path = f"./{item_name}.png"
|
66 |
print(f"Saving image to {output_image_path}")
|
67 |
font_path = "./fonts/Balgruf.ttf"
|
68 |
italics_font_path = './fonts/BalgrufItalic.ttf'
|
@@ -77,12 +77,7 @@ def render_text_on_card(image_path, item_name,
|
|
77 |
type_center_position = (384, 545)
|
78 |
type_area_width = 600
|
79 |
type_area_height = 45
|
80 |
-
type_text =
|
81 |
-
if len(item_weight) >= 1:
|
82 |
-
type_text = type_text + ' '+ item_weight
|
83 |
-
|
84 |
-
if len(item_damage) >= 1 :
|
85 |
-
type_text = type_text + ' '+ item_damage
|
86 |
|
87 |
# Description box properties
|
88 |
description_position = (105, 630)
|
@@ -101,24 +96,22 @@ def render_text_on_card(image_path, item_name,
|
|
101 |
|
102 |
# open image and render text
|
103 |
image = u.open_image_from_url(image_path)
|
104 |
-
image = rend.render_text_with_dynamic_spacing(image,
|
105 |
image = rend.render_text_with_dynamic_spacing(image,type_text , type_center_position, type_area_width, type_area_height,font_path,initial_font_size)
|
106 |
-
image = rend.render_text_with_dynamic_spacing(image,
|
107 |
-
#
|
108 |
-
paste_image_and_resize(image, value_overlay_path,x_position= 0,y_position=0, img_width= 768, img_height= 1024)
|
109 |
-
image = rend.render_text_with_dynamic_spacing(image, item_value, value_position, value_area_width, value_area_height,font_path,initial_font_size)
|
110 |
-
image = rend.render_text_with_dynamic_spacing(image, item_quote, quote_position, quote_area_width, quote_area_height,italics_font_path,initial_font_size, quote = True)
|
111 |
#Paste Sizzek Sticker
|
112 |
-
paste_image_and_resize(image, sticker_path_dictionary,x_position= 0,y_position=909, img_width= 115, img_height= 115, purchased_item_key=
|
113 |
|
114 |
# Add blur, gives it a less artificial look, put into list and return the list since gallery requires lists
|
115 |
image = image.filter(ImageFilter.GaussianBlur(.5))
|
116 |
image_list.append(image)
|
117 |
|
118 |
-
|
|
|
119 |
|
120 |
|
121 |
-
|
122 |
|
123 |
|
124 |
|
|
|
3 |
import utilities as u
|
4 |
import ast
|
5 |
from urllib.request import urlopen
|
6 |
+
import urllib.parse
|
7 |
|
8 |
def save_image(image,item_key):
|
9 |
image.save(f"{item_key['Name']}.png")
|
|
|
13 |
#shop_inventory = inv.inventory
|
14 |
#purchased_item_key = shop_inventory['Shortsword']
|
15 |
#border_path = './card_templates/Shining Sunset Border.png'
|
16 |
+
base_path = "https://media.githubusercontent.com/media/Drakosfire/CardGenerator/refs/heads/pet-generator/card_parts/"
|
17 |
+
# value_overlay_path = f"{base_path}Value_box_transparent.png"
|
18 |
test_item = {'Name': 'Pustulent Raspberry', 'Type': 'Fruit', 'Value': '1 cp', 'Properties': ['Unusual Appearance', 'Rare Taste'], 'Weight': '0.2 lb', 'Description': 'This small fruit has a pustulent appearance, with bumps and irregular shapes covering its surface. Its vibrant colors and strange texture make it an oddity among other fruits.', 'Quote': 'A fruit that defies expectations, as sweet and sour as life itself.', 'SD Prompt': 'A small fruit with vibrant colors and irregular shapes, bumps covering its surface.'}
|
19 |
+
sticker_path_dictionary = {'Default': urllib.parse.urljoin(base_path, urllib.parse.quote("Sizzek Sticker.png")),
|
20 |
+
'Common': urllib.parse.urljoin(base_path, urllib.parse.quote("Common.png")),
|
21 |
+
'Uncommon': urllib.parse.urljoin(base_path, urllib.parse.quote("Uncommon.png")),
|
22 |
+
'Rare': urllib.parse.urljoin(base_path, urllib.parse.quote("Rare.png")),
|
23 |
+
'Very Rare':urllib.parse.urljoin(base_path, urllib.parse.quote("Very Rare.png")),
|
24 |
+
'Legendary':urllib.parse.urljoin(base_path, urllib.parse.quote("Legendary.png"))}
|
25 |
|
26 |
|
27 |
# Function that takes in an image url and a dictionary and uses the values to print onto a card.
|
|
|
50 |
# Paste the resized image onto the base image
|
51 |
base_image.paste(image_to_paste_resized, paste_position, image_to_paste_resized)
|
52 |
|
53 |
+
def render_text_on_card(image_path, pet_name,
|
54 |
+
pet_species,
|
55 |
+
pet_breed,
|
56 |
+
pet_fur,
|
57 |
+
pet_intelligence,
|
58 |
+
pet_affection,
|
59 |
+
pet_energy,
|
60 |
+
pet_noise,
|
61 |
+
pet_play) :
|
62 |
# Card Properties
|
63 |
image_list = []
|
64 |
+
pet_properties = f"Intelligence : {pet_intelligence} \n Affection : {pet_affection} \n Energy : {pet_energy} \n Noise : {pet_noise} \n Play : {pet_play}"
|
65 |
+
output_image_path = f"./{pet_name}.png"
|
|
|
66 |
print(f"Saving image to {output_image_path}")
|
67 |
font_path = "./fonts/Balgruf.ttf"
|
68 |
italics_font_path = './fonts/BalgrufItalic.ttf'
|
|
|
77 |
type_center_position = (384, 545)
|
78 |
type_area_width = 600
|
79 |
type_area_height = 45
|
80 |
+
type_text = f"{pet_breed} Color and Fur : {pet_fur}"
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
# Description box properties
|
83 |
description_position = (105, 630)
|
|
|
96 |
|
97 |
# open image and render text
|
98 |
image = u.open_image_from_url(image_path)
|
99 |
+
image = rend.render_text_with_dynamic_spacing(image, pet_name, title_center_position, title_area_width, title_area_height,font_path,initial_font_size)
|
100 |
image = rend.render_text_with_dynamic_spacing(image,type_text , type_center_position, type_area_width, type_area_height,font_path,initial_font_size)
|
101 |
+
image = rend.render_text_with_dynamic_spacing(image, pet_properties, description_position, description_area_width, description_area_height,font_path,initial_font_size, description = True)
|
102 |
+
# paste_image_and_resize(image, value_overlay_path,x_position= 0,y_position=0, img_width= 768, img_height= 1024)
|
|
|
|
|
|
|
103 |
#Paste Sizzek Sticker
|
104 |
+
paste_image_and_resize(image, sticker_path_dictionary['Default'],x_position= 0,y_position=909, img_width= 115, img_height= 115, purchased_item_key= None)
|
105 |
|
106 |
# Add blur, gives it a less artificial look, put into list and return the list since gallery requires lists
|
107 |
image = image.filter(ImageFilter.GaussianBlur(.5))
|
108 |
image_list.append(image)
|
109 |
|
110 |
+
image = image.save(f"./output/{pet_name}.png")
|
111 |
+
|
112 |
|
113 |
|
114 |
+
return image_list
|
115 |
|
116 |
|
117 |
|
img2img.py
CHANGED
@@ -2,40 +2,98 @@ import time
|
|
2 |
import utilities as u
|
3 |
import card_generator as card
|
4 |
from PIL import Image
|
5 |
-
import
|
6 |
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
|
|
|
|
|
|
8 |
|
9 |
start_time = time.time()
|
10 |
temp_image_path = "./image_temp/"
|
11 |
|
12 |
|
13 |
|
14 |
-
def preview_and_generate_image(num_images,sd_prompt, user_input_template
|
15 |
-
|
16 |
-
|
17 |
-
print(
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
"
|
24 |
-
|
25 |
-
"input_template":card_template
|
26 |
|
27 |
-
}
|
28 |
-
)
|
29 |
-
|
30 |
-
|
31 |
-
img_time = time.time() - img_start
|
32 |
-
img_its = 35/img_time
|
33 |
-
print(f"image gen time = {img_time} and {img_its} it/s")
|
34 |
-
|
35 |
-
total_time = time.time() - start_time
|
36 |
-
print(total_time)
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
|
41 |
|
|
|
2 |
import utilities as u
|
3 |
import card_generator as card
|
4 |
from PIL import Image
|
5 |
+
import fal_client
|
6 |
from pathlib import Path
|
7 |
+
import tempfile
|
8 |
+
import os
|
9 |
+
import base64
|
10 |
+
import io
|
11 |
+
import logging
|
12 |
+
import requests
|
13 |
+
import json
|
14 |
|
15 |
+
# Set up logging
|
16 |
+
logging.basicConfig(level=logging.INFO)
|
17 |
+
logger = logging.getLogger(__name__)
|
18 |
|
19 |
start_time = time.time()
|
20 |
temp_image_path = "./image_temp/"
|
21 |
|
22 |
|
23 |
|
24 |
+
def preview_and_generate_image(num_images, sd_prompt, user_input_template):
|
25 |
+
print(f"num_images: {num_images}")
|
26 |
+
print(f"sd_prompt: {sd_prompt}")
|
27 |
+
print(f"user_input_template: {user_input_template}")
|
28 |
+
num_images = int(4)
|
29 |
+
sd_prompt = f"magnum opus, blank card, no text, blank textboxes, detailed high quality animal properties borders, {sd_prompt}"
|
30 |
+
try:
|
31 |
+
# Save the image to a temporary file
|
32 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_file:
|
33 |
+
user_input_template[0].save(temp_file.name, format="PNG")
|
34 |
+
temp_path = temp_file.name
|
|
|
35 |
|
36 |
+
logger.info(f"Image saved to temporary file: {temp_path}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
+
# Upload the file using fal_client
|
39 |
+
url = fal_client.upload_file(temp_path)
|
40 |
+
logger.info(f"Image uploaded. URL: {url}")
|
41 |
+
|
42 |
+
# Remove the temporary file
|
43 |
+
os.unlink(temp_path)
|
44 |
+
|
45 |
+
request_handle = fal_client.submit(
|
46 |
+
"fal-ai/flux-lora/image-to-image",
|
47 |
+
arguments={
|
48 |
+
"num_inference_steps": 35,
|
49 |
+
"prompt": sd_prompt,
|
50 |
+
"num_images": num_images,
|
51 |
+
"image_url": url,
|
52 |
+
"strength": 0.85
|
53 |
+
}
|
54 |
+
)
|
55 |
+
|
56 |
+
logger.info(f"Type of request_handle: {type(request_handle)}")
|
57 |
+
logger.info(f"Content of request_handle: {request_handle}")
|
58 |
+
|
59 |
+
# Get the result from the SyncRequestHandle
|
60 |
+
result = request_handle.get()
|
61 |
+
|
62 |
+
logger.info(f"Type of result: {type(result)}")
|
63 |
+
logger.info(f"Content of result: {json.dumps(result, indent=2)}")
|
64 |
+
|
65 |
+
# Extract the image URLs from the result
|
66 |
+
image_urls = [img['url'] for img in result.get('images', [])]
|
67 |
+
|
68 |
+
logger.info(f"Extracted image URLs: {image_urls}")
|
69 |
+
|
70 |
+
if not image_urls:
|
71 |
+
logger.warning("No images were generated.")
|
72 |
+
return []
|
73 |
+
|
74 |
+
# Download and process the images
|
75 |
+
images = []
|
76 |
+
for i, url in enumerate(image_urls):
|
77 |
+
try:
|
78 |
+
response = requests.get(url)
|
79 |
+
response.raise_for_status() # Raises an HTTPError for bad responses
|
80 |
+
img = Image.open(io.BytesIO(response.content))
|
81 |
+
images.append((img, f"Generated Image {i+1}")) # Add a tuple with image and caption
|
82 |
+
logger.info(f"Successfully downloaded and processed image {i+1}")
|
83 |
+
except Exception as e:
|
84 |
+
logger.error(f"Error processing image {i+1} from URL {url}: {str(e)}")
|
85 |
+
|
86 |
+
if not images:
|
87 |
+
logger.warning("No images could be downloaded and processed.")
|
88 |
+
return []
|
89 |
+
|
90 |
+
logger.info(f"Returning {len(images)} processed images")
|
91 |
+
return images
|
92 |
+
|
93 |
+
except Exception as e:
|
94 |
+
logger.error(f"Error during API call or processing: {str(e)}")
|
95 |
+
logger.exception("Full traceback:")
|
96 |
+
return []
|
97 |
|
98 |
|
99 |
|
item_dict_gen.py
CHANGED
@@ -1,359 +1,283 @@
|
|
1 |
-
import replicate
|
2 |
import ast
|
3 |
import gc
|
4 |
-
import
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
|
|
|
|
|
|
|
|
26 |
return llm_output
|
27 |
|
28 |
-
|
29 |
-
# Evaluate if string is dictionary literal
|
30 |
-
try:
|
31 |
-
result = ast.literal_eval(string)
|
32 |
-
if isinstance(result, dict):
|
33 |
-
print("Item dictionary is valid")
|
34 |
-
return result
|
35 |
-
# If not, modify by attempting to add brackets to where they tend to fail to generate.
|
36 |
-
else:
|
37 |
-
modified_string = '{' + string
|
38 |
-
if isinstance(modified_string, dict):
|
39 |
-
return modified_string
|
40 |
-
modified_string = string + '}'
|
41 |
-
if isinstance(modified_string, dict):
|
42 |
-
return modified_string
|
43 |
-
modified_string = '{' + string + '}'
|
44 |
-
if isinstance(modified_string, dict):
|
45 |
-
return modified_string
|
46 |
-
except (ValueError, SyntaxError) :
|
47 |
-
print("Dictionary not valid")
|
48 |
-
return None
|
49 |
-
|
50 |
-
|
51 |
-
# Instructions past 4 are not time tested and may need to be removed.
|
52 |
-
### Meta prompted :
|
53 |
-
prompt_instructions = """ **Purpose**: ONLY Generate a structured inventory entry for a specific item as a hashmap. Do NOT reply with anything other than a hashmap.
|
54 |
|
55 |
**Instructions**:
|
56 |
-
1. Replace `{item}` with the name of the user item, DO NOT CHANGE THE USER ITEM NAME enclosed in single quotes (e.g., `'Magic Wand'`).
|
57 |
-
2. **Dictionary Structure**:
|
58 |
-
|
59 |
-
{"{item}": {
|
60 |
-
'Name': "{item name}",
|
61 |
-
'Type': '{item type}',
|
62 |
-
'Rarity': '{item rarity},
|
63 |
-
'Value': '{item value}',
|
64 |
-
'Properties': ["{property1}", "{property2}", ...],
|
65 |
-
'Damage': '{damage formula} , '{damage type}',
|
66 |
-
'Weight': '{weight}',
|
67 |
-
'Description': "{item description}",
|
68 |
-
'Quote': "{item quote}",
|
69 |
-
'SD Prompt': "{special description for the item}"
|
70 |
-
} }
|
71 |
-
3. Weapons MUST have a key 'Damage'
|
72 |
-
4. The description should be brief and puncy, or concise and thoughtful.
|
73 |
-
5. The quote and SD Prompt MUST be inside double quotations ie " ".
|
74 |
-
6. The quote is from the perspective of someone commenting on the impact of the {item} on their life
|
75 |
-
7. Value should be assigned as an integer of copper pieces (cp), silver pieces (sp), electrum pieces (ep), gold pieces (gp), and platinum pieces (pp).
|
76 |
-
8. Use this table for reference on value :
|
77 |
-
1 cp 1 lb. of wheat
|
78 |
-
2 cp 1 lb. of flour or one chicken
|
79 |
-
5 cp 1 lb. of salt
|
80 |
-
1 sp 1 lb. of iron or 1 sq. yd. of canvas
|
81 |
-
5 sp 1 lb. of copper or 1 sq. yd. of cotton cloth
|
82 |
-
1 gp 1 lb. of ginger or one goat
|
83 |
-
2 gp 1 lb. of cinnamon or pepper, or one sheep
|
84 |
-
3 gp 1 lb. of cloves or one pig
|
85 |
-
5 gp 1 lb. of silver or 1 sq. yd. of linen
|
86 |
-
10 gp 1 sq. yd. of silk or one cow
|
87 |
-
15 gp 1 lb. of saffron or one ox
|
88 |
-
50 gp 1 lb. of gold
|
89 |
-
500 gp 1 lb. of platinum
|
90 |
-
|
91 |
-
|
92 |
-
300 gp +1 Melee or Ranged Weapon
|
93 |
-
2000 gp +2 Melee or Ranged Weapon
|
94 |
-
10000 gp +3 Melee or Ranged Weapon
|
95 |
-
300 gp +1 Armor Uncommon
|
96 |
-
2000 gp +2 Armor Rare
|
97 |
-
10000 gp +3 Armor Very Rare
|
98 |
-
300 gp +1 Shield Uncommon
|
99 |
-
2000 gp +2 Shield Rare
|
100 |
-
10000 gp +3 Shield Very Rare
|
101 |
-
|
102 |
-
9. Examples of Magical Scroll Value:
|
103 |
-
Common: 50-100 gp
|
104 |
-
Uncommon: 101-500 gp
|
105 |
-
Rare: 501-5000 gp
|
106 |
-
Very rare: 5001-50000 gp
|
107 |
-
Legendary: 50001+ gp
|
108 |
-
|
109 |
-
A scroll's rarity depends on the spell's level:
|
110 |
-
Cantrip-1: Common
|
111 |
-
2-3: Uncommon
|
112 |
-
4-5: Rare
|
113 |
-
6-8: Very rare
|
114 |
-
9: Legendary
|
115 |
-
|
116 |
-
10. Explanation of Mimics:
|
117 |
-
Mimics are shapeshifting predators able to take on the form of inanimate objects to lure creatures to their doom. In dungeons, these cunning creatures most often take the form of doors and chests, having learned that such forms attract a steady stream of prey.
|
118 |
-
Imitative Predators. Mimics can alter their outward texture to resemble wood, stone, and other basic materials, and they have evolved to assume the appearance of objects that other creatures are likely to come into contact with. A mimic in its altered form is nearly unrecognizable until potential prey blunders into its reach, whereupon the monster sprouts pseudopods and attacks.
|
119 |
-
When it changes shape, a mimic excretes an adhesive that helps it seize prey and weapons that touch it. The adhesive is absorbed when the mimic assumes its amorphous form and on parts the mimic uses to move itself.
|
120 |
-
Cunning Hunters. Mimics live and hunt alone, though they occasionally share their feeding grounds with other creatures. Although most mimics have only predatory intelligence, a rare few evolve greater cunning and the ability to carry on simple conversations in Common or Undercommon. Such mimics might allow safe passage through their domains or provide useful information in exchange for food.
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
{"Cloak of Whispering Shadows": {
|
130 |
-
'Name': 'Cloak of Whispering Shadows',
|
131 |
-
'Type': 'Cloak',
|
132 |
-
'Rarity': 'Very Rare',
|
133 |
-
'Value': '7500 gp',
|
134 |
-
'Properties': ["Grants invisibility in dim light or darkness","Allows communication with shadows for gathering information"],
|
135 |
-
'Weight': '1 lb',
|
136 |
-
'Description': "A cloak woven from the essence of twilight, blending its wearer into the shadows. Whispers of the past and present linger in its folds, offering secrets to those who listen.",
|
137 |
-
'Quote': "In the embrace of night, secrets surface in the silent whispers of the dark.",
|
138 |
-
'SD Prompt': " Cloak of deep indigo almost black, swirling patterns that shift and move with every step. As it drapes over one's shoulders, an eerie connection forms between the wearer and darkness itself."
|
139 |
-
} }
|
140 |
-
|
141 |
-
2. Health Potion Entry:
|
142 |
-
|
143 |
-
{"Health Potion": {
|
144 |
-
'Name' : "Health Portion",
|
145 |
-
'Type' : 'Potion',
|
146 |
-
'Rarity' : 'Common',
|
147 |
-
'Value': '50 gp',
|
148 |
-
'Properties': ["Quafable", "Restores 1d4 + 2 HP upon consumption"],
|
149 |
-
'Weight': '0.5 lb',
|
150 |
-
'Description': "Contained within this small vial is a crimson liquid that sparkles when shaken, a life-saving elixir for those who brave the unknown.",
|
151 |
-
'Quote': "To the weary, a drop of hope; to the fallen, a chance to stand once more.",
|
152 |
-
'SD Prompt' : " a small, delicate vial containing a sparkling crimson liquid. Emit a soft glow, suggesting its restorative properties. The vial is set against a dark, ambiguous background."
|
153 |
-
} }
|
154 |
-
|
155 |
-
3. Wooden Shield Entry:
|
156 |
-
|
157 |
-
{"Wooden Shield": {
|
158 |
-
'Name' : "Wooden Shield",
|
159 |
-
'Type' : 'Armor, Shield',
|
160 |
-
'Rarity': 'Common',
|
161 |
-
'Value': '10 gp',
|
162 |
-
'Properties': ["+2 AC"],
|
163 |
-
'Weight': '6 lb',
|
164 |
-
'Description': "Sturdy and reliable, this wooden shield is a simple yet effective defense against the blows of adversaries.",
|
165 |
-
'Quote': "In the rhythm of battle, it dances - a barrier between life and defeat.",
|
166 |
-
'SD Prompt': " a sturdy wooden shield, a symbol of defense, with a simple yet solid design. The shield, has visible grain patterns and a few battle scars. It stands as a steadfast protector, embodying the essence of a warrior's resilience in the face of adversity."
|
167 |
-
} }
|
168 |
-
|
169 |
-
4. Helmet of Perception Entry:
|
170 |
-
|
171 |
-
{"Helmet of Perception": {
|
172 |
-
'Name' : "Helmet of Perception",
|
173 |
-
'Type' : 'Magical Item (armor, helmet)',
|
174 |
-
'Rarity': 'Very Rare',
|
175 |
-
'Value': '3000 gp',
|
176 |
-
'Properties': ["+ 1 to AC", "Grants the wearer advantage on perception checks", "+5 to passive perception"],
|
177 |
-
'Weight': '3 lb',
|
178 |
-
'Description': "Forged from mystic metals and enchanted with ancient spells, this helmet offers protection beyond the physical realm.",
|
179 |
-
'Quote': "A crown not of royalty, but of unyielding vigilance, warding off the unseen threats that lurk in the shadows.",
|
180 |
-
'SD Prompt': " a mystical helmet crafted from enchanted metals, glowing with subtle runes. imbued with spells, radiates a mystical aura, symbolizing enhanced perception and vigilance,elegant,formidable"
|
181 |
-
} }
|
182 |
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
'Type': 'Ranged Weapon (martial, longbow)',
|
188 |
-
'Rarity': 'Common',
|
189 |
-
'Value': '50 gp',
|
190 |
-
'Properties': ["2-handed", "Range 150/600", "Loading"],
|
191 |
-
'Damage': '1d8 + Dex, piercing',
|
192 |
-
'Weight': '6 lb',
|
193 |
-
'Description': "With a sleek and elegant design, this longbow is crafted for speed and precision, capable of striking down foes from a distance.",
|
194 |
-
'Quote': "From the shadows it emerges, a silent whisper of steel that pierces the veil of darkness, bringing justice to those who dare to trespass.",
|
195 |
-
'SD Prompt' : "a longbow with intricate carvings and stone inlay with a black string"
|
196 |
-
} }
|
197 |
|
198 |
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
"
|
237 |
-
"
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
"
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import ast
|
2 |
import gc
|
3 |
+
from openai import OpenAI
|
4 |
+
|
5 |
+
client = OpenAI()
|
6 |
+
|
7 |
+
def load_llm(user_input, prompt_instructions):
|
8 |
+
prompt = f"{user_input}"
|
9 |
+
print(prompt)
|
10 |
+
response = client.chat.completions.create(
|
11 |
+
model="gpt-4o-2024-08-06",
|
12 |
+
messages=[
|
13 |
+
{
|
14 |
+
"role": "user",
|
15 |
+
"content": f"{prompt_instructions} {prompt}"
|
16 |
+
}
|
17 |
+
],
|
18 |
+
temperature=1,
|
19 |
+
max_tokens=500,
|
20 |
+
top_p=1,
|
21 |
+
frequency_penalty=0,
|
22 |
+
presence_penalty=0
|
23 |
+
)
|
24 |
+
print(f"Model : {response.model}")
|
25 |
+
return response.choices[0].message.content
|
26 |
+
# Call the LLM and store its output
|
27 |
+
def call_llm_and_cleanup(user_input, inventory = False):
|
28 |
+
|
29 |
+
prompt_instructions = f"{pet_prompt_instructions}"
|
30 |
|
31 |
+
llm_output = load_llm(user_input, prompt_instructions)
|
32 |
+
llm_output = "".join(llm_output)
|
33 |
+
print(f"llm_output = {llm_output}")
|
34 |
+
# llm_output is still available for use here
|
35 |
return llm_output
|
36 |
|
37 |
+
pet_prompt_instructions = """ **Purpose**: ONLY Generate a structured json following the provided format. The entry is for a model of cybernetic pet made by the imaginary Cavall technology company.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
**Instructions**:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
1. Only output structured data. The file structure starts with { and ends with } it is CRITICAL to end with a }
|
42 |
+
2. Do not enclose the output in any other characters such as ''' or json
|
43 |
+
3. DO NOT use null, use "".
|
44 |
+
4. All keys and values MUST be enclosed in double quotes.
|
45 |
+
5. Replace `{pet}` with the name of the user pet, DO NOT CHANGE THE USER pet NAME enclosed in single quotes (e.g., `'Magic Wand'`).
|
46 |
+
6. Ensure your request is formatted as a hashmap.
|
47 |
+
7. The cybernetic pets are friendly and cute, they are products and toys.
|
48 |
+
8. The descriptions should be brief and puncy, or concise and in the voice of a judge at a high end cat or dog or pet exhibition such as the American Kennel Clube or Cat Fancier and make specific callout of how mild, and well camoflaughed the artificiality of the cybernetic pet is.
|
49 |
+
9. The Image Prompt MUST be inside double quotations ie " ".
|
50 |
|
51 |
+
|
52 |
+
**Format Example**:
|
53 |
+
- **Dictionary Structure**:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
+
{"{Pet}": {
|
56 |
+
"Name": '{Pet Name}',
|
57 |
+
"Pet Species": '{pet species}',
|
58 |
+
"Breed": '{pet breed},
|
59 |
+
"Fur" : "The colors and quality of the pet's fur,
|
60 |
+
"Intelligence Level" : "How intelligent the pet is and how it demonstrates it",
|
61 |
+
"Affection Level" : "How affectionate and how the pet shows it,
|
62 |
+
"Energy Level" : "The Energy level",
|
63 |
+
"Noise Level" : "The volume, frequency, triggers, and type",
|
64 |
+
"Play Level" : " The level of play and types enjoyed",
|
65 |
+
"Image Prompt" : "Descriptive imagery for an image generator"
|
66 |
+
}
|
67 |
|
68 |
+
- **Input Placeholder**:
|
69 |
+
- "{pet}": Replace with the pet name, ensuring it's wrapped in single quotes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
|
72 |
+
**Output Examples**:
|
73 |
+
1. Mignon the Toy Sized Chihuahua
|
74 |
+
|
75 |
+
{"Mignon": {
|
76 |
+
"Name": "Mignon”
|
77 |
+
"Pet Species": Dog,
|
78 |
+
"Breed" : ”Chihuahua (Toy)”,
|
79 |
+
"Fur" : “Cream, smooth shorthair”,
|
80 |
+
"Intelligence Level" : “Medium-high, tr'inable but stubborn”,
|
81 |
+
"Affection Level" : “High but selective, prefers favorite humans”,
|
82 |
+
"Energy Level" : “High”,
|
83 |
+
"Noise Level" : “Very high, yappy”,
|
84 |
+
"Play Level" : “Low“, Fetch, chase“
|
85 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) Chihuahua, boasting a luscious cream coat and an attitude that's equal parts feisty and affectionate. Note the subtle glow behind her eyes, a hint of advanced biometrics enhancing her already keen senses."
|
86 |
+
}
|
87 |
+
|
88 |
+
|
89 |
+
2. Marmalade the Austrailian Shepherd Herding Dog
|
90 |
+
|
91 |
+
{"Marmalade":{
|
92 |
+
"Name":"Marmalade",
|
93 |
+
"Breed" : ”Australian Shepherd (Herding)”,
|
94 |
+
"Pet Species": Dog,
|
95 |
+
"Fur" : “Blue merle with white markings and tan points, medium double coat”,
|
96 |
+
"Intelligence Level" : “Very high, suitable for jobs”,
|
97 |
+
"Affection Level" : “High”,
|
98 |
+
"Energy Level" : “Very high”,
|
99 |
+
"Noise Level" : “Medium, piercing”,
|
100 |
+
"Play Level" : “Very high, Agility, herding, obedience, frisbee, puzzles”,
|
101 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) an Australian Shepherd of impeccable breeding, showcasing a stunning blue merle coat and the intelligence to match."
|
102 |
+
}
|
103 |
+
|
104 |
+
3. Holden Clawfield the Pembroke Welsh Corgi Herding Dog
|
105 |
+
|
106 |
+
{“Holden Clawfield”:{
|
107 |
+
"Name" : "Holden Clawfield",
|
108 |
+
"Breed" : ”Pembroke Welsh Corgi (Herding)”,
|
109 |
+
"Pet Species": Dog,
|
110 |
+
"Fur" : “Fawn with white markings, short double coat”,
|
111 |
+
"Intelligence Level" : “High, trainable',
|
112 |
+
"Affection Level" : “Very high, loves humans and other Pets”,
|
113 |
+
"Energy Level" : “High”,
|
114 |
+
"Noise Level" : “High, piercing”,
|
115 |
+
"Play Level" : “High, Toys, herding, obedience”,
|
116 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) a Pembroke Welsh Corgi of noble bearing, flaunting a rich fawn coat and an endearing personality."
|
117 |
+
}
|
118 |
+
|
119 |
+
4. Tyr the Great Pyr the Great Pyreness Working Dog
|
120 |
+
|
121 |
+
{“Tyr the Great Pyr”:{
|
122 |
+
"Name" : "Tyr the Great Pyr",
|
123 |
+
"Breed" : ”Great Pyrenees (Working)”,
|
124 |
+
"Pet Species": Dog,
|
125 |
+
"Fur" : “White, medium double coat”,
|
126 |
+
"Intelligence Level" : “Medium, trainable to a point”,
|
127 |
+
"Affection Level" : “Medium, wary of strangers”,
|
128 |
+
"Energy Level" : “Low, mostly lazy but vigilant”,
|
129 |
+
"Noise Level" : “Medium, will bark to alert”,
|
130 |
+
"Play Level" : “Medium, not motivated by play, Toys, treats”,
|
131 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar)a Great Pyrenees of regal demeanor, White, medium double coat and an air of quiet confidence. Playing with a toy"
|
132 |
+
}
|
133 |
+
|
134 |
+
5. Emperor Maximus the Great Dane Working Dog
|
135 |
+
|
136 |
+
{“Emperor Maximus”:{
|
137 |
+
"Name" : "Emperor Maximus",
|
138 |
+
"Breed" : ”Great Dane (Working)”,
|
139 |
+
"Pet Species": Dog,
|
140 |
+
"Fur" : “Black and white with black mask, smooth shorthair”,
|
141 |
+
"Intelligence Level" : “Medium, trainable”,
|
142 |
+
"Affection Level" : “Very high, needy”,
|
143 |
+
"Energy Level" : “Medium, enjoys hiking”,
|
144 |
+
"Noise Level" : “Medium, will bark to alert”,
|
145 |
+
"Play Level" : “Medium, Chase, tug”,
|
146 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) a Great Dane of imposing stature, Black and white with black mask, smooth shorthair and a gentle giant's disposition."
|
147 |
+
}
|
148 |
+
|
149 |
+
6. Becks the Airedale Terrier Dog
|
150 |
+
|
151 |
+
{“Becks”:{
|
152 |
+
"Name" : "Becks",
|
153 |
+
"Breed" : ”Airedale Terrier (Terrier)”,
|
154 |
+
"Pet Species": Dog,
|
155 |
+
"Fur" : “Black and tan, medium wiry coat”,
|
156 |
+
"Intelligence Level" : “Medium, respond well to training”,
|
157 |
+
"Affection Level" : “Medium, reserved”,
|
158 |
+
"Energy Level" : “High, alert and active”,
|
159 |
+
"Noise Level" : “Medium, vigilant watchdog”,
|
160 |
+
"Play Level" : “Medium, Fetch, toys, treats”,
|
161 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) an Airedale Terrier of rugged charm, displaying a handsome black and tan coat and a reserved yet."
|
162 |
+
}
|
163 |
+
|
164 |
+
7. Blue Carolina the Plott Hound
|
165 |
+
|
166 |
+
{“Blue Carolina”:{
|
167 |
+
"Name": "Blue Carolina"
|
168 |
+
"Breed" : ”Plott Hound (Hound)”,
|
169 |
+
"Pet Species": Dog,
|
170 |
+
"Fur" : “Chocolate brindle, smooth shorthair”,
|
171 |
+
"Intelligence Level" : “High, driven and trainable”,
|
172 |
+
"Affection Level" : “High, very sweet”,
|
173 |
+
"Energy Level" : “High, alert and active”,
|
174 |
+
"Noise Level" : “Medium, will bark to alert”,
|
175 |
+
"Play Level" : “Medium, more active than playful, Toys, frisbee, chase”,
|
176 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) Blue Carolina, a Plott Hound of athletic build, showcasing a rich chocolate brindle coat and a high-energy personality.
|
177 |
+
}
|
178 |
+
|
179 |
+
8. Sekhmet the Sphynx Cat
|
180 |
+
{“Sekhmet”:{
|
181 |
+
"Name" : "Sekhmet",
|
182 |
+
"Breed" : “Sphynx”,
|
183 |
+
"Pet Species" : "Cat",
|
184 |
+
"Fur" : “Hairless, light brown”,
|
185 |
+
"Intelligence Level" : “High, trainable',
|
186 |
+
"Affection Level" : “High but selective, prefers favorite human”,
|
187 |
+
"Energy Level" : “Low, reserved”,
|
188 |
+
"Noise Level" : “Low, mostly quiet”,
|
189 |
+
"Play Level" : “Low, lazy, Cuddling, lap time, shoulder perching”,
|
190 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar)Sphynx Cat, Hairless, light brown Cuddling, lap time, shoulder perching."
|
191 |
+
}
|
192 |
+
|
193 |
+
9. Smith the American Shorthair Cat
|
194 |
+
|
195 |
+
{“Smith”:{
|
196 |
+
"Name" : "Smith",
|
197 |
+
"Breed" : “American Shorthair”,
|
198 |
+
"Pet Species" : "Cat",
|
199 |
+
"Fur" : “Black”,
|
200 |
+
"Intelligence Level" : “Medium, somewhat trainable”,
|
201 |
+
"Affection Level" : “High, loves humans and other Pets”,
|
202 |
+
"Energy Level" : “Medium”,
|
203 |
+
"Noise Level" : “Low, infrequent meows”,
|
204 |
+
"Play Level" : “Medium, Belly rubs, hunting, toys”,
|
205 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) American Shorthair Black Fur playing with a toy"
|
206 |
+
}
|
207 |
+
|
208 |
+
10. Catherine of Atagon and Her Royal Highness Elizabth I
|
209 |
+
|
210 |
+
{“Catherine of Aragon and Her Royal Highness Elizabeth I”:{
|
211 |
+
"Name" : "Catherine of Aragon and Her Royal Highness Elizabeth I",
|
212 |
+
"Breed" : “British Shorthair”,
|
213 |
+
"Pet Species" : "Cat",
|
214 |
+
"Fur" : “Brown and black tortoise shell, black and silver tabby”,
|
215 |
+
"Intelligence Level" : “Medium, not int'rested in training”,
|
216 |
+
"Affection Level" : “Medium-low, independent”,
|
217 |
+
"Energy Level" : “Low, very lazy”,
|
218 |
+
"Noise Level" : “Medium, will speak their minds”,
|
219 |
+
"Play Level" : “Low, not interested in play, Treats, naps, perching/observing”,
|
220 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur) (Glowing pet collar) British Shorthair, Brown and black tortoise shell, black and silver tabby perched on a table"
|
221 |
+
}
|
222 |
+
|
223 |
+
|
224 |
+
11. Kitsune the Cream Flame Point Longhair Ragdoll
|
225 |
+
|
226 |
+
{“Kitsune”:{
|
227 |
+
"Name" : "Kitsune",
|
228 |
+
"Breed" : “Ragdoll”,
|
229 |
+
"Pet Species" : "Cat",
|
230 |
+
"Fur" : “Cream flame point, longhair”,
|
231 |
+
"Intelligence Level" : “Low, slow to learn”,
|
232 |
+
"Affection Level" : “High, loves attention”,
|
233 |
+
"Energy Level" : “High, always moving”,
|
234 |
+
"Noise Level" : “Medium, chirpy meows”,
|
235 |
+
"Play Level" : “High, will play with anything or anyone, Toys, catnip, running, cuddling”,
|
236 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur) (Glowing pet collar) Ragdoll Cream flame point, longhair stretching "
|
237 |
+
}
|
238 |
+
|
239 |
+
|
240 |
+
12. Blucifer the Russian Blue Shorthair
|
241 |
+
|
242 |
+
{“Blucifer”:{
|
243 |
+
"Name" : "Blucifer",
|
244 |
+
"Breed" : “Russian Blue”,
|
245 |
+
"Pet Species" : "Cat",
|
246 |
+
"Fur" : “Blue-gray, smooth shorthair”,
|
247 |
+
"Intelligence Level" : “High, very trainable”,
|
248 |
+
"Affection Level" : “Medium, selectively affectionate”,
|
249 |
+
"Energy Level" : “Medium, more alert than active”,
|
250 |
+
"Noise Level" : “Low, almost silent”,
|
251 |
+
"Play Level" : “Low, more active than playful, Treats, lap time”,
|
252 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur) (Glowing pet collar) Russian Blue with Blue-gray smooth shorthair, curled up in a lap "
|
253 |
+
}
|
254 |
+
|
255 |
+
12. Dirk Thuderpaw the Maine Coon with Brown Stripes
|
256 |
+
{'Dirk Thunderpaw':{
|
257 |
+
"Name" : "Dirk Thunderpaw",
|
258 |
+
"Breed" : “Maine Coon”,
|
259 |
+
"Pet Species" : "Cat",
|
260 |
+
"Fur" : “Brown stripes, white face, dense longhair”,
|
261 |
+
"Intelligence Level" : “Medium, trainable”,
|
262 |
+
"Affection Level" : “Medium, affectionate with most people”,
|
263 |
+
"Energy Level" : “Low, will spring to alertness”,
|
264 |
+
"Noise Level" : “Low, rarely meows”,
|
265 |
+
"Play Level" : “Medium, more interested in training, Hunting”,
|
266 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur) (Glowing pet collar) Maine Coon Brown stripes, white face, dense longhair hunting a toy "
|
267 |
+
}
|
268 |
+
|
269 |
+
13. Scrambles Mcgee, Esquire the Gray Persian With Thick Longhair
|
270 |
+
|
271 |
+
{'Scrambles McGee Esquire':{
|
272 |
+
"Name" : "Scrambles McGee Esquire",
|
273 |
+
"Breed" : “Persian,
|
274 |
+
"Pet Species" : "Cat",
|
275 |
+
"Fur" : “Gray, thick longhair”,
|
276 |
+
"Intelligence Level" : “Low, not interested in training”,
|
277 |
+
"Affection Level" : “Low, very selectively affectionate”,
|
278 |
+
"Energy Level" : “Low, very lazy”,
|
279 |
+
"Noise Level" : “High, frequent meows”,
|
280 |
+
"Play Level" : “Low, very lazy, Naps, lap time, treats”,
|
281 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur) (Glowing pet collar) Persian Gray with thick longhair, very lazy napping "
|
282 |
+
}
|
283 |
+
"""
|
user_input.py
CHANGED
@@ -38,23 +38,9 @@ def user_pick_item(user_prompt,list_of_items):
|
|
38 |
def call_llm(user_input):
|
39 |
# Process the query and get the response
|
40 |
llm_call = igen.call_llm_and_cleanup(user_input)
|
41 |
-
response = llm_call
|
42 |
-
|
43 |
-
|
44 |
-
index = response.find(end_phrase)
|
45 |
-
print(f"index = {index}")
|
46 |
-
if index != -1:
|
47 |
-
# Slice the string from the end of the phrase onwards
|
48 |
-
response = response[index + len(end_phrase):]
|
49 |
-
else:
|
50 |
-
# Phrase not found, optional handling
|
51 |
-
response = response
|
52 |
-
|
53 |
-
response = response.replace("GPT4 Assistant: ", "")
|
54 |
-
print(response)
|
55 |
-
response = igen.convert_to_dict(response)
|
56 |
-
if not response:
|
57 |
-
response = call_llm(user_input)
|
58 |
del llm_call
|
59 |
return response
|
60 |
|
|
|
38 |
def call_llm(user_input):
|
39 |
# Process the query and get the response
|
40 |
llm_call = igen.call_llm_and_cleanup(user_input)
|
41 |
+
response = u.string_to_dict(llm_call)
|
42 |
+
print(f"response = {response}")
|
43 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
del llm_call
|
45 |
return response
|
46 |
|
utilities.py
CHANGED
@@ -8,6 +8,10 @@ from github import Github
|
|
8 |
image_list = []
|
9 |
# Utility Functions to be called from all modules
|
10 |
|
|
|
|
|
|
|
|
|
11 |
# Function to return a list of keys of a nested dictionary using it's key value (item or creature)
|
12 |
def keys_list(dict, index):
|
13 |
keys_list=list(dict.keys())
|
|
|
8 |
image_list = []
|
9 |
# Utility Functions to be called from all modules
|
10 |
|
11 |
+
# Function to convert a string to a dictionary
|
12 |
+
def string_to_dict(string):
|
13 |
+
return eval(string)
|
14 |
+
|
15 |
# Function to return a list of keys of a nested dictionary using it's key value (item or creature)
|
16 |
def keys_list(dict, index):
|
17 |
keys_list=list(dict.keys())
|