Spaces:
Runtime error
Runtime error
Delete software_engineer_agent.py
Browse files- software_engineer_agent.py +0 -42
software_engineer_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/software_engineer_mellum"
|
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 |
-
"""Software Engineer generates clean, modern UI code using best practices"""
|
16 |
-
messages = state["messages"]
|
17 |
-
prompt = messages[-1].content
|
18 |
-
|
19 |
-
# Enhance the prompt with UI implementation guidelines
|
20 |
-
enhanced_prompt = f"""
|
21 |
-
Generate modern, clean UI code following these guidelines:
|
22 |
-
1. Use Tailwind CSS for styling (recommended for consistent spacing and responsive design)
|
23 |
-
2. Implement proper semantic HTML structure
|
24 |
-
3. Use CSS Grid and Flexbox for layouts
|
25 |
-
4. Add proper ARIA labels for accessibility
|
26 |
-
5. Implement responsive breakpoints
|
27 |
-
6. Use CSS variables for consistent theming
|
28 |
-
7. Add proper error handling and loading states
|
29 |
-
8. Implement proper component structure
|
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": "Software Engineer", "content": output}],
|
41 |
-
"dev_output": output,
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|