curiouscurrent commited on
Commit
028acfc
·
verified ·
1 Parent(s): 4767a8a

Update backend_agent/api_generator.py

Browse files
Files changed (1) hide show
  1. backend_agent/api_generator.py +4 -4
backend_agent/api_generator.py CHANGED
@@ -8,13 +8,14 @@ model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)
8
 
9
  def generate_backend_code_llm(task_name):
10
  """
11
- Generate Python REST/GraphQL backend code for a task
12
  """
13
  prompt = f"""
14
- You are an expert backend developer. Generate Python code for a REST or GraphQL API for this backend task:
 
15
  Task: {task_name}
16
 
17
- Include routes/resolvers, input validation placeholders, and comments.
18
  """
19
  inputs = tokenizer(prompt, return_tensors="pt")
20
  outputs = model.generate(**inputs, max_new_tokens=350)
@@ -22,5 +23,4 @@ Include routes/resolvers, input validation placeholders, and comments.
22
 
23
  if "Task:" in code:
24
  code = code.split("Task:")[-1].strip()
25
-
26
  return code
 
8
 
9
  def generate_backend_code_llm(task_name):
10
  """
11
+ Generates Python backend code (REST/GraphQL) for a given task using LLM.
12
  """
13
  prompt = f"""
14
+ You are an expert backend developer. Generate Python code for REST or GraphQL APIs
15
+ for the following task:
16
  Task: {task_name}
17
 
18
+ Include routes/resolvers, input validation, and placeholders for business logic.
19
  """
20
  inputs = tokenizer(prompt, return_tensors="pt")
21
  outputs = model.generate(**inputs, max_new_tokens=350)
 
23
 
24
  if "Task:" in code:
25
  code = code.split("Task:")[-1].strip()
 
26
  return code