Spaces:
Sleeping
Sleeping
Create whalecore/agents.py
Browse files- whalecore/agents.py +30 -0
whalecore/agents.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import yaml
|
2 |
+
|
3 |
+
class Agent:
|
4 |
+
def __init__(self, name, persona, instructions):
|
5 |
+
self.name = name
|
6 |
+
self.persona = persona
|
7 |
+
self.instructions = instructions
|
8 |
+
|
9 |
+
def chat(self, message):
|
10 |
+
# Placeholder logic for chatting
|
11 |
+
return f"Hello from {self.name}! You said: {message[:260]}..."
|
12 |
+
|
13 |
+
def load_agents(config_path="agentsConfig.YAML"):
|
14 |
+
with open(config_path, 'r') as f:
|
15 |
+
config = yaml.safe_load(f)
|
16 |
+
agents = []
|
17 |
+
for agent_conf in config.get('agents', []):
|
18 |
+
agent = Agent(
|
19 |
+
name=agent_conf['name'],
|
20 |
+
persona=agent_conf['persona'],
|
21 |
+
instructions=agent_conf['instructions']
|
22 |
+
)
|
23 |
+
agents.append(agent)
|
24 |
+
return agents
|
25 |
+
|
26 |
+
def run_agents_on_text(agent_list, text):
|
27 |
+
results = {}
|
28 |
+
for agent in agent_list:
|
29 |
+
results[agent.name] = agent.chat(text)
|
30 |
+
return results
|