AmnaHassan commited on
Commit
768c65d
·
verified ·
1 Parent(s): 3f2301c

Create agents.py

Browse files
Files changed (1) hide show
  1. agents.py +18 -0
agents.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langgraph import Agent, Workflow
2
+ from model_utils import generate_text, run_activation_patching
3
+
4
+ class ExperimentAgent(Agent):
5
+ def run(self, prompt):
6
+ text = generate_text(prompt)
7
+ activations = run_activation_patching(prompt)
8
+ return {"generated_text": text, "activations": activations}
9
+
10
+ class ExplanationAgent(Agent):
11
+ def run(self, activations):
12
+ explanation = "Layer 5 and 7 had the most influence on the model output."
13
+ return explanation
14
+
15
+ workflow = Workflow()
16
+ workflow.add_agent("experiment", ExperimentAgent())
17
+ workflow.add_agent("explanation", ExplanationAgent())
18
+ workflow.connect("experiment", "explanation", lambda result: result["activations"])