Skip to content

Commit 4ad774c

Browse files
committed
chore: Minor fixes.
1 parent b070fa6 commit 4ad774c

File tree

4 files changed

+98
-74
lines changed

4 files changed

+98
-74
lines changed

src/dqa/client/a2a_mixin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ async def obtain_a2a_client(
3434
final_agent_card_to_use = _public_card
3535

3636
client = ClientFactory(
37-
config=ClientConfig(
38-
streaming=True, polling=False, httpx_client=httpx_client
39-
)
37+
config=ClientConfig(streaming=True, polling=True, httpx_client=httpx_client)
4038
).create(card=final_agent_card_to_use)
4139
logger.info("A2A client initialised.")
4240
return client, final_agent_card_to_use

src/dqa/executor/mhqa.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self):
1919
self._actor_mhqa = MHQAActor.__name__
2020
self._factory = ActorProxyFactory(retry_policy=RetryPolicy(max_attempts=1))
2121

22-
async def do_mhqa_response(self, data: MHQAInput):
22+
async def do_mhqa_respond(self, data: MHQAInput):
2323
proxy = ActorProxy.create(
2424
actor_type=self._actor_mhqa,
2525
actor_id=ActorId(actor_id=data.thread_id),
@@ -37,9 +37,8 @@ async def do_mhqa_response(self, data: MHQAInput):
3737
raw_body=data.model_dump_json().encode(),
3838
)
3939
return result.decode().strip("\"'")
40-
# Start listening to the pub-sub topic for responses (non-blocking)
4140

42-
async def do_get_history(self, data: MHQAHistoryInput) -> str:
41+
async def do_mhqa_get_history(self, data: MHQAHistoryInput) -> str:
4342
proxy = ActorProxy.create(
4443
actor_type=self._actor_mhqa,
4544
actor_id=ActorId(actor_id=data.thread_id),
@@ -49,7 +48,7 @@ async def do_get_history(self, data: MHQAHistoryInput) -> str:
4948
result = await proxy.invoke_method(method=MHQAActorMethods.GetChatHistory)
5049
return result.decode().strip("\"'")
5150

52-
async def do_delete_history(self, data: MHQADeleteHistoryInput) -> str:
51+
async def do_mhqa_delete_history(self, data: MHQADeleteHistoryInput) -> str:
5352
proxy = ActorProxy.create(
5453
actor_type=self._actor_mhqa,
5554
actor_id=ActorId(actor_id=data.thread_id),
@@ -75,11 +74,11 @@ async def execute(self, context: RequestContext, event_queue: EventQueue):
7574
response = None
7675
match message_payload.skill:
7776
case MHQAAgentSkills.Respond:
78-
response = await self.do_mhqa_response(data=message_payload.data)
77+
response = await self.do_mhqa_respond(data=message_payload.data)
7978
case MHQAAgentSkills.GetChatHistory:
80-
response = await self.do_get_history(data=message_payload.data)
79+
response = await self.do_mhqa_get_history(data=message_payload.data)
8180
case MHQAAgentSkills.ResetChatHistory:
82-
response = await self.do_delete_history(data=message_payload.data)
81+
response = await self.do_mhqa_delete_history(data=message_payload.data)
8382
case _:
8483
raise ValueError(f"Unknown skill '{message_payload.skill}' requested!")
8584
if response:

src/dqa/web/gradio.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,17 @@ async def btn_echo_clicked(
370370
),
371371
)
372372

373-
chat_history.extend(
373+
waiting_messages = (
374374
self.convert_mhqa_response_to_chat_messages(
375375
MHQAResponse(
376-
thread_id=selected_chat_id, user_input=txt_input
376+
thread_id=selected_chat_id,
377+
user_input=txt_input,
378+
agent_output="...",
377379
)
378380
)
379381
)
380-
last_added_messages = 1
382+
chat_history.extend(waiting_messages)
383+
last_added_messages = len(waiting_messages)
381384

382385
yield (
383386
None,
@@ -420,16 +423,16 @@ async def btn_echo_clicked(
420423
browser_state_chat_histories[selected_chat_id] = (
421424
chat_history
422425
)
426+
yield (
427+
None,
428+
browser_state_chat_histories,
429+
selected_chat_id,
430+
chat_history,
431+
)
423432
else:
424433
gr.Warning(
425434
f"No input message was provided for chat ID {selected_chat_id}."
426435
)
427-
yield (
428-
None,
429-
browser_state_chat_histories,
430-
selected_chat_id,
431-
chat_history,
432-
)
433436
except Exception as e:
434437
yield (
435438
gr.update(value="", interactive=True),

0 commit comments

Comments
 (0)