Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,7 @@ Don't write anything else except the character description in json format and do
|
|
44 |
world_description_prompt = "Generate a unique and random world description (Don't Write anything else except the world description)."
|
45 |
|
46 |
def get_random_world_description():
|
47 |
-
|
48 |
model="Qwen/Qwen3-235B-A22B",
|
49 |
messages=[
|
50 |
{
|
@@ -53,7 +53,10 @@ def get_random_world_description():
|
|
53 |
}
|
54 |
],
|
55 |
)
|
56 |
-
|
|
|
|
|
|
|
57 |
|
58 |
def get_random_persona_description():
|
59 |
return ds.shuffle().select([100])[0]["persona"]
|
@@ -84,12 +87,15 @@ def generate_character(world_description, persona_description, progress=gr.Progr
|
|
84 |
}
|
85 |
],
|
86 |
)
|
87 |
-
|
|
|
|
|
|
|
88 |
return output
|
89 |
|
90 |
app_description = """
|
91 |
- This app generates a character in JSON format based on a persona description and a world description.
|
92 |
-
- The character's appearance is generated using [FLUX-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev) and the character description is generated using [
|
93 |
- The persona description is randomly selected from the [FinePersonas-Lite](https://huggingface.co/datasets/MohamedRashad/FinePersonas-Lite) dataset.
|
94 |
|
95 |
**Note:** I recommend starting with the world description (you can write one or loop over randomly generated ones) and then try different persona descriptions to generate interesting characters for the world you created.
|
|
|
44 |
world_description_prompt = "Generate a unique and random world description (Don't Write anything else except the world description)."
|
45 |
|
46 |
def get_random_world_description():
|
47 |
+
response = llm_client.chat.completions.create(
|
48 |
model="Qwen/Qwen3-235B-A22B",
|
49 |
messages=[
|
50 |
{
|
|
|
53 |
}
|
54 |
],
|
55 |
)
|
56 |
+
result = response.choices[0].message.content
|
57 |
+
if "</think>" in result:
|
58 |
+
result = result[result.index("</think>")+1:]
|
59 |
+
return result.choices[0].message.content
|
60 |
|
61 |
def get_random_persona_description():
|
62 |
return ds.shuffle().select([100])[0]["persona"]
|
|
|
87 |
}
|
88 |
],
|
89 |
)
|
90 |
+
result = response.choices[0].message.content
|
91 |
+
if "</think>" in result:
|
92 |
+
result = result[result.index("</think>")+1:]
|
93 |
+
output = json.loads(result)
|
94 |
return output
|
95 |
|
96 |
app_description = """
|
97 |
- This app generates a character in JSON format based on a persona description and a world description.
|
98 |
+
- The character's appearance is generated using [FLUX-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev) and the character description is generated using [Qwen3-235B-A22B](https://huggingface.co/Qwen/Qwen3-235B-A22B).
|
99 |
- The persona description is randomly selected from the [FinePersonas-Lite](https://huggingface.co/datasets/MohamedRashad/FinePersonas-Lite) dataset.
|
100 |
|
101 |
**Note:** I recommend starting with the world description (you can write one or loop over randomly generated ones) and then try different persona descriptions to generate interesting characters for the world you created.
|