Spaces:
Runtime error
Runtime error
Delete ui_designer_agent.py
Browse files- ui_designer_agent.py +0 -42
ui_designer_agent.py
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
2 |
-
import torch
|
3 |
-
from langchain_core.messages import AIMessage
|
4 |
-
|
5 |
-
MODEL_REPO = "Rahul-8799/ui_designer_mistral" # You'll need to fine-tune this model
|
6 |
-
|
7 |
-
tokenizer = AutoTokenizer.from_pretrained(MODEL_REPO, trust_remote_code=True)
|
8 |
-
model = AutoModelForCausalLM.from_pretrained(
|
9 |
-
MODEL_REPO,
|
10 |
-
torch_dtype=torch.float16,
|
11 |
-
device_map="auto"
|
12 |
-
)
|
13 |
-
|
14 |
-
def run(state: dict) -> dict:
|
15 |
-
"""UI Designer creates beautiful and structured UI designs with proper spacing and layout"""
|
16 |
-
messages = state["messages"]
|
17 |
-
prompt = messages[-1].content
|
18 |
-
|
19 |
-
# Enhance the prompt with UI design principles
|
20 |
-
enhanced_prompt = f"""
|
21 |
-
Create a beautiful and well-structured UI design following these principles:
|
22 |
-
1. Use proper spacing and padding (recommended: 1rem/16px for padding, 2rem/32px for margins)
|
23 |
-
2. Implement a consistent color scheme
|
24 |
-
3. Ensure proper hierarchy with clear headings
|
25 |
-
4. Use responsive design principles
|
26 |
-
5. Implement proper grid system
|
27 |
-
6. Add smooth transitions and hover effects
|
28 |
-
7. Ensure proper contrast and readability
|
29 |
-
8. Use modern UI components and patterns
|
30 |
-
|
31 |
-
Original requirements: {prompt}
|
32 |
-
"""
|
33 |
-
|
34 |
-
input_ids = tokenizer(enhanced_prompt, return_tensors="pt").input_ids.to(model.device)
|
35 |
-
output_ids = model.generate(input_ids, max_new_tokens=3000)
|
36 |
-
output = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
37 |
-
|
38 |
-
return {
|
39 |
-
"messages": [AIMessage(content=output)],
|
40 |
-
"chat_log": state["chat_log"] + [{"role": "UI Designer", "content": output}],
|
41 |
-
"ui_design_output": output,
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|