curiouscurrent commited on
Commit
aea6581
·
verified ·
1 Parent(s): 55bc1ce

Update coordinator/task_assigner.py

Browse files
Files changed (1) hide show
  1. coordinator/task_assigner.py +22 -8
coordinator/task_assigner.py CHANGED
@@ -1,13 +1,27 @@
1
  # coordinator/task_assigner.py
 
 
 
 
 
 
 
 
2
 
3
  def assign_tasks(tasks):
4
  """
5
- Minimal assignment logic for demonstration
6
  """
7
- assigned = {}
8
- for task in tasks:
9
- if "authentication" in task or "task sharing" in task:
10
- assigned[task] = "Backend Agent"
11
- else:
12
- assigned[task] = "Frontend Agent"
13
- return assigned
 
 
 
 
 
 
 
1
  # coordinator/task_assigner.py
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+ import torch
4
+
5
+ # Reuse the same small OPT model
6
+ MODEL_NAME = "facebook/opt-125m"
7
+
8
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
9
+ model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)
10
 
11
  def assign_tasks(tasks):
12
  """
13
+ Use LLM to assign tasks to Frontend or Backend agents
14
  """
15
+ task_text = "\n".join(f"- {task}" for task in tasks)
16
+ prompt = f"Assign the following technical tasks to either Frontend or Backend agent:\n{task_text}\n\nAssignments:"
17
+ inputs = tokenizer(prompt, return_tensors="pt")
18
+ outputs = model.generate(**inputs, max_new_tokens=150)
19
+ decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
20
+
21
+ # Parse into dict
22
+ assignments = {}
23
+ for line in decoded.split("\n"):
24
+ if "->" in line:
25
+ task, agent = line.split("->")
26
+ assignments[task.strip()] = agent.strip()
27
+ return assignments