Spaces:
Sleeping
Sleeping
Update agents/programmer.py
Browse files- agents/programmer.py +2 -33
agents/programmer.py
CHANGED
|
@@ -1,36 +1,5 @@
|
|
| 1 |
-
from
|
| 2 |
-
from agents.base_agent import BaseAgent, ACPMessage
|
| 3 |
|
| 4 |
class ProgrammerAgent(BaseAgent):
|
| 5 |
def __init__(self):
|
| 6 |
-
super().__init__(name="Aymaan", role="
|
| 7 |
-
self.model_id = "microsoft/phi-1_5"
|
| 8 |
-
|
| 9 |
-
self.tokenizer = AutoTokenizer.from_pretrained(self.model_id)
|
| 10 |
-
self.model = AutoModelForCausalLM.from_pretrained(self.model_id)
|
| 11 |
-
|
| 12 |
-
def receive_message(self, message: ACPMessage) -> ACPMessage:
|
| 13 |
-
# Greeting shortcut
|
| 14 |
-
if self.is_greeting(message.content):
|
| 15 |
-
return ACPMessage(
|
| 16 |
-
sender=self.name,
|
| 17 |
-
receiver=message.sender,
|
| 18 |
-
performative="inform",
|
| 19 |
-
content="Hey there! I'm Aymaan, your coding buddy. 😊"
|
| 20 |
-
)
|
| 21 |
-
|
| 22 |
-
prompt = f"{message.content}"
|
| 23 |
-
inputs = self.tokenizer(prompt, return_tensors="pt").to(self.model.device)
|
| 24 |
-
outputs = self.model.generate(
|
| 25 |
-
**inputs,
|
| 26 |
-
max_new_tokens=100,
|
| 27 |
-
do_sample=True,
|
| 28 |
-
temperature=0.7
|
| 29 |
-
)
|
| 30 |
-
reply = self.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 31 |
-
return ACPMessage(
|
| 32 |
-
sender=self.name,
|
| 33 |
-
receiver=message.sender,
|
| 34 |
-
performative="inform",
|
| 35 |
-
content=reply.strip()
|
| 36 |
-
)
|
|
|
|
| 1 |
+
from agents.base_agent import BaseAgent
|
|
|
|
| 2 |
|
| 3 |
class ProgrammerAgent(BaseAgent):
|
| 4 |
def __init__(self):
|
| 5 |
+
super().__init__(name="Aymaan", role="Programmer 🖥️")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|