switch to hysts/zephyr-7b
Browse files
src/App.svelte
CHANGED
@@ -93,7 +93,7 @@
|
|
93 |
);
|
94 |
|
95 |
rwkvClient = await gradioClient.Client.connect(
|
96 |
-
"
|
97 |
opts
|
98 |
);
|
99 |
|
|
|
93 |
);
|
94 |
|
95 |
rwkvClient = await gradioClient.Client.connect(
|
96 |
+
"hysts/zephyr-7b",
|
97 |
opts
|
98 |
);
|
99 |
|
src/lib/components/MonsterGenerator/MonsterGenerator.svelte
CHANGED
@@ -22,7 +22,7 @@
|
|
22 |
});
|
23 |
|
24 |
// Prompt templates
|
25 |
-
const MONSTER_CONCEPT_PROMPT = (caption: string) => `
|
26 |
|
27 |
Come up with a monster idea (in the vein of Pokémon) that incorporates properties of what the pictured object is.
|
28 |
Assess how unique the pictured object is. If the image is not very unique then it should result in weak & common monster.
|
@@ -41,18 +41,14 @@ Include:
|
|
41 |
- Physical appearance and distinguishing features
|
42 |
- Special abilities or powers
|
43 |
- Personality traits
|
44 |
-
- Habitat or origin
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
const IMAGE_GENERATION_PROMPT = (concept: string) => `User: Convert this monster concept into a clear and succinct description of its appearance:
|
49 |
"${concept}"
|
50 |
|
51 |
-
Include all of its visual details, format the description as a single long sentence
|
52 |
-
|
53 |
-
Assistant:`;
|
54 |
|
55 |
-
const MONSTER_STATS_PROMPT = (concept: string) => `
|
56 |
|
57 |
"${concept}"
|
58 |
|
@@ -90,7 +86,7 @@ Here is the output schema:
|
|
90 |
|
91 |
Remember to base the stats on how unique/powerful the original object was. Common objects should have lower stats, unique objects should have higher stats.
|
92 |
|
93 |
-
|
94 |
|
95 |
async function handleImageSelected(file: File) {
|
96 |
if (!joyCaptionClient || !rwkvClient || !fluxClient) {
|
@@ -208,27 +204,24 @@ Assistant: \`\`\`json`;
|
|
208 |
}
|
209 |
|
210 |
const conceptPrompt = MONSTER_CONCEPT_PROMPT(state.imageCaption);
|
|
|
211 |
|
212 |
console.log('Generating monster concept with prompt:', conceptPrompt);
|
213 |
|
214 |
try {
|
215 |
-
const output = await rwkvClient.predict(
|
216 |
-
conceptPrompt,
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
0.
|
221 |
-
0.
|
|
|
|
|
222 |
]);
|
223 |
|
224 |
-
console.log('
|
225 |
-
let conceptText = output.data
|
226 |
-
|
227 |
-
// Drop any text after "User:" to prevent additional prompting
|
228 |
-
const userIndex = conceptText.indexOf('User:');
|
229 |
-
if (userIndex !== -1) {
|
230 |
-
conceptText = conceptText.substring(0, userIndex).trim();
|
231 |
-
}
|
232 |
|
233 |
state.monsterConcept = conceptText;
|
234 |
console.log('Monster concept generated:', state.monsterConcept);
|
@@ -249,27 +242,24 @@ Assistant: \`\`\`json`;
|
|
249 |
}
|
250 |
|
251 |
const promptGenerationPrompt = IMAGE_GENERATION_PROMPT(state.monsterConcept);
|
|
|
252 |
|
253 |
console.log('Generating image prompt from concept');
|
254 |
|
255 |
try {
|
256 |
-
const output = await rwkvClient.predict(
|
257 |
-
promptGenerationPrompt,
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
0.
|
262 |
-
0.
|
|
|
|
|
263 |
]);
|
264 |
|
265 |
console.log('Image prompt output:', output);
|
266 |
-
let promptText = output.data
|
267 |
-
|
268 |
-
// Drop any text after "User:" to prevent additional prompting
|
269 |
-
const userIndex = promptText.indexOf('User:');
|
270 |
-
if (userIndex !== -1) {
|
271 |
-
promptText = promptText.substring(0, userIndex).trim();
|
272 |
-
}
|
273 |
|
274 |
state.imagePrompt = promptText;
|
275 |
console.log('Image prompt generated:', state.imagePrompt);
|
@@ -342,27 +332,24 @@ Assistant: \`\`\`json`;
|
|
342 |
}
|
343 |
|
344 |
const statsPrompt = MONSTER_STATS_PROMPT(state.monsterConcept);
|
|
|
345 |
|
346 |
console.log('Generating monster stats from concept');
|
347 |
|
348 |
try {
|
349 |
-
const output = await rwkvClient.predict(
|
350 |
-
statsPrompt,
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
0.
|
355 |
-
0.
|
|
|
|
|
356 |
]);
|
357 |
|
358 |
console.log('Stats output:', output);
|
359 |
-
let jsonString = output.data
|
360 |
-
|
361 |
-
// Drop any text after "User:" to prevent additional prompting
|
362 |
-
const userIndex = jsonString.indexOf('User:');
|
363 |
-
if (userIndex !== -1) {
|
364 |
-
jsonString = jsonString.substring(0, userIndex).trim();
|
365 |
-
}
|
366 |
|
367 |
// Extract JSON from the response (remove markdown if present)
|
368 |
let cleanJson = jsonString;
|
|
|
22 |
});
|
23 |
|
24 |
// Prompt templates
|
25 |
+
const MONSTER_CONCEPT_PROMPT = (caption: string) => `Based on this image caption: "${caption}"
|
26 |
|
27 |
Come up with a monster idea (in the vein of Pokémon) that incorporates properties of what the pictured object is.
|
28 |
Assess how unique the pictured object is. If the image is not very unique then it should result in weak & common monster.
|
|
|
41 |
- Physical appearance and distinguishing features
|
42 |
- Special abilities or powers
|
43 |
- Personality traits
|
44 |
+
- Habitat or origin`;
|
45 |
|
46 |
+
const IMAGE_GENERATION_PROMPT = (concept: string) => `Convert this monster concept into a clear and succinct description of its appearance:
|
|
|
|
|
47 |
"${concept}"
|
48 |
|
49 |
+
Include all of its visual details, format the description as a single long sentence.`;
|
|
|
|
|
50 |
|
51 |
+
const MONSTER_STATS_PROMPT = (concept: string) => `Convert the following monster concept into a JSON object with stats:
|
52 |
|
53 |
"${concept}"
|
54 |
|
|
|
86 |
|
87 |
Remember to base the stats on how unique/powerful the original object was. Common objects should have lower stats, unique objects should have higher stats.
|
88 |
|
89 |
+
Respond with only valid JSON.`;
|
90 |
|
91 |
async function handleImageSelected(file: File) {
|
92 |
if (!joyCaptionClient || !rwkvClient || !fluxClient) {
|
|
|
204 |
}
|
205 |
|
206 |
const conceptPrompt = MONSTER_CONCEPT_PROMPT(state.imageCaption);
|
207 |
+
const systemPrompt = "You are a creative monster designer. Create unique and interesting monsters based on real-world objects, considering their properties and characteristics.";
|
208 |
|
209 |
console.log('Generating monster concept with prompt:', conceptPrompt);
|
210 |
|
211 |
try {
|
212 |
+
const output = await rwkvClient.predict("/chat", [
|
213 |
+
conceptPrompt, // message
|
214 |
+
[], // chat_history
|
215 |
+
systemPrompt, // system_prompt
|
216 |
+
1024, // max_new_tokens
|
217 |
+
0.7, // temperature
|
218 |
+
0.95, // top_p
|
219 |
+
50, // top_k
|
220 |
+
1.0 // repetition_penalty
|
221 |
]);
|
222 |
|
223 |
+
console.log('Zephyr output:', output);
|
224 |
+
let conceptText = output.data;
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
|
226 |
state.monsterConcept = conceptText;
|
227 |
console.log('Monster concept generated:', state.monsterConcept);
|
|
|
242 |
}
|
243 |
|
244 |
const promptGenerationPrompt = IMAGE_GENERATION_PROMPT(state.monsterConcept);
|
245 |
+
const systemPrompt = "You are an expert at creating visual descriptions for image generation. Provide clear, detailed visual descriptions.";
|
246 |
|
247 |
console.log('Generating image prompt from concept');
|
248 |
|
249 |
try {
|
250 |
+
const output = await rwkvClient.predict("/chat", [
|
251 |
+
promptGenerationPrompt, // message
|
252 |
+
[], // chat_history
|
253 |
+
systemPrompt, // system_prompt
|
254 |
+
600, // max_new_tokens
|
255 |
+
0.7, // temperature
|
256 |
+
0.95, // top_p
|
257 |
+
50, // top_k
|
258 |
+
1.0 // repetition_penalty
|
259 |
]);
|
260 |
|
261 |
console.log('Image prompt output:', output);
|
262 |
+
let promptText = output.data;
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
|
264 |
state.imagePrompt = promptText;
|
265 |
console.log('Image prompt generated:', state.imagePrompt);
|
|
|
332 |
}
|
333 |
|
334 |
const statsPrompt = MONSTER_STATS_PROMPT(state.monsterConcept);
|
335 |
+
const systemPrompt = "You are a game designer specializing in monster stats and abilities. Always respond with valid JSON that matches the provided schema exactly.";
|
336 |
|
337 |
console.log('Generating monster stats from concept');
|
338 |
|
339 |
try {
|
340 |
+
const output = await rwkvClient.predict("/chat", [
|
341 |
+
statsPrompt, // message
|
342 |
+
[], // chat_history
|
343 |
+
systemPrompt, // system_prompt
|
344 |
+
800, // max_new_tokens - more for JSON
|
345 |
+
0.3, // temperature - lower for structured output
|
346 |
+
0.95, // top_p
|
347 |
+
50, // top_k
|
348 |
+
1.0 // repetition_penalty
|
349 |
]);
|
350 |
|
351 |
console.log('Stats output:', output);
|
352 |
+
let jsonString = output.data;
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
|
354 |
// Extract JSON from the response (remove markdown if present)
|
355 |
let cleanJson = jsonString;
|