ea4all-gradio-agents-mcp-hackathon-tools-refactoring-vqa-safety-status
Browse files- ea4all/ea4all_mcp.py +2 -2
- ea4all/src/ea4all_vqa/graph.py +9 -14
- ea4all/src/ea4all_vqa/state.py +1 -1
ea4all/ea4all_mcp.py
CHANGED
@@ -132,7 +132,7 @@ async def run_vqa_agentic_system(question: str, diagram: str, request: gr.Reques
|
|
132 |
|
133 |
vqa_image = diagram
|
134 |
response = await diagram_graph.ainvoke({"question":msg, "image": vqa_image}, config)
|
135 |
-
chat_memory.append(ChatMessage(role="assistant", content=response['messages'][-1].content))
|
136 |
|
137 |
yield chat_memory
|
138 |
|
@@ -160,7 +160,7 @@ async def run_reference_architecture_agentic_system(business_query: str) -> Asyn
|
|
160 |
input=inputs,
|
161 |
config=config
|
162 |
) #astream not loading the graph
|
163 |
-
yield response
|
164 |
|
165 |
async def run_pmo_agentic_system(question:str) -> AsyncGenerator[list, None]:
|
166 |
"""
|
|
|
132 |
|
133 |
vqa_image = diagram
|
134 |
response = await diagram_graph.ainvoke({"question":msg, "image": vqa_image}, config)
|
135 |
+
chat_memory.append(ChatMessage(role="assistant", content=response['messages'][-1].content if len(response['messages']) else response['safety_status']['description']))
|
136 |
|
137 |
yield chat_memory
|
138 |
|
|
|
160 |
input=inputs,
|
161 |
config=config
|
162 |
) #astream not loading the graph
|
163 |
+
yield response
|
164 |
|
165 |
async def run_pmo_agentic_system(question:str) -> AsyncGenerator[list, None]:
|
166 |
"""
|
ea4all/src/ea4all_vqa/graph.py
CHANGED
@@ -193,22 +193,13 @@ Given the conversation above, is the image safe to be processed? Does the image
|
|
193 |
safe_request = result['isSafe']
|
194 |
description = result['description']
|
195 |
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
result = True
|
200 |
-
else:
|
201 |
-
print("---ROUTE REQUEST TO FINISH---")
|
202 |
-
print(f"Architecture Diagram: {architecture_image} --- isSafe: {safe_request} -- What is it? {description}")
|
203 |
-
result = False
|
204 |
-
|
205 |
-
return {'safety_status': result}
|
206 |
|
207 |
-
def call_finish(state):
|
208 |
return {
|
209 |
-
"state": state,
|
210 |
"messages": [],
|
211 |
-
"
|
212 |
}
|
213 |
|
214 |
def make_supervisor_node(model: BaseChatModel, members: list[str]) -> RunnableLambda:
|
@@ -352,7 +343,11 @@ def enter_graph(state:OverallState, config:RunnableConfig) -> Command[Literal['s
|
|
352 |
}
|
353 |
|
354 |
async def choose_next(state: OverallState):
|
355 |
-
|
|
|
|
|
|
|
|
|
356 |
|
357 |
def build_vqa_graph():
|
358 |
model = get_llm_client(BaseConfiguration.supervisor_model, api_base_url="", streaming=BaseConfiguration.streaming)
|
|
|
193 |
safe_request = result['isSafe']
|
194 |
description = result['description']
|
195 |
|
196 |
+
return {"safety_status": result}
|
197 |
+
|
198 |
+
def call_finish(state:OverallState, config:RunnableConfig) -> dict:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
|
|
|
200 |
return {
|
|
|
201 |
"messages": [],
|
202 |
+
"safety_status": getattr(state, 'safety_status', {}),
|
203 |
}
|
204 |
|
205 |
def make_supervisor_node(model: BaseChatModel, members: list[str]) -> RunnableLambda:
|
|
|
343 |
}
|
344 |
|
345 |
async def choose_next(state: OverallState):
|
346 |
+
"""Choose the next node based on the safety status."""
|
347 |
+
isArcihitectureImage = getattr(state, 'safety_status', {}).get('isArchitectureImage', False)
|
348 |
+
isSafe = getattr(state, 'safety_status', {}).get('isSafe', False)
|
349 |
+
|
350 |
+
return "diagram_supervisor" if isArcihitectureImage and isSafe else "final"
|
351 |
|
352 |
def build_vqa_graph():
|
353 |
model = get_llm_client(BaseConfiguration.supervisor_model, api_base_url="", streaming=BaseConfiguration.streaming)
|
ea4all/src/ea4all_vqa/state.py
CHANGED
@@ -44,7 +44,7 @@ class OutputState:
|
|
44 |
"""
|
45 |
|
46 |
messages: Optional[Annotated[Sequence[MessagesState], operator.add]] = None
|
47 |
-
safety_status: Optional[
|
48 |
|
49 |
"""Attributes:
|
50 |
safety_status: safety status of the diagram provided by the user
|
|
|
44 |
"""
|
45 |
|
46 |
messages: Optional[Annotated[Sequence[MessagesState], operator.add]] = None
|
47 |
+
safety_status: Optional[dict[str,str]] = None
|
48 |
|
49 |
"""Attributes:
|
50 |
safety_status: safety status of the diagram provided by the user
|