Skip to content

Commit a1a5a9f

Browse files
authored
Merge pull request #618 from YashPandit4u/a2a-agents-on-md
A2A Unnecessary Comments removed
2 parents 6302738 + 9dbbb0a commit a1a5a9f

File tree

4 files changed

+1
-100
lines changed

4 files changed

+1
-100
lines changed

model-deployment/A2A_agents_on_MD/agent_a/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ RUN uv sync
1414
EXPOSE 9999
1515

1616
# Run the app
17-
# CMD ["python", "-m", "__main__"]
1817
CMD ["uv", "run", "."]

model-deployment/A2A_agents_on_MD/agent_a/__main__.py

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -151,103 +151,6 @@ async def __call__(self, scope, receive, send):
151151
scope["path"] = "/"
152152
await self.app(scope, receive, send)
153153

154-
# Test Client Function (for standalone testing)
155-
async def test_client_main() -> None:
156-
PUBLIC_AGENT_CARD_PATH = '/.well-known/agent.json'
157-
EXTENDED_AGENT_CARD_PATH = '/agent/authenticatedExtendedCard'
158-
logging.basicConfig(level=logging.INFO)
159-
logger = logging.getLogger(__name__)
160-
161-
base_url = 'https://modeldeployment.us-ashburn-1.oci.customer-oci.com/ocid1.tenancy.oc1..aaaaaaaafwgqzxcwlkkpl5i334qpv62s375upsw2j4ufgcizfnnhjd4l55ia/agent-a/predict'
162-
async with httpx.AsyncClient(auth=get_auth(), verify=False, headers={"Content-Length": "0"}) as httpx_client:
163-
resolver = A2ACardResolver(
164-
httpx_client=httpx_client,
165-
base_url=base_url,
166-
)
167-
final_agent_card_to_use: AgentCard | None = None
168-
try:
169-
logger.info(
170-
f'Attempting to fetch public agent card from: {base_url}{PUBLIC_AGENT_CARD_PATH}'
171-
)
172-
_public_card = (
173-
await resolver.get_agent_card()
174-
)
175-
logger.info('Successfully fetched public agent card:')
176-
logger.info(
177-
_public_card.model_dump_json(indent=2, exclude_none=True)
178-
)
179-
final_agent_card_to_use = _public_card
180-
logger.info(
181-
'\nUsing PUBLIC agent card for client initialization (default).'
182-
)
183-
if _public_card.supportsAuthenticatedExtendedCard:
184-
try:
185-
logger.info(
186-
f'\nPublic card supports authenticated extended card. Attempting to fetch from: {base_url}{EXTENDED_AGENT_CARD_PATH}'
187-
)
188-
auth_headers_dict = {
189-
'Authorization': 'Bearer dummy-token-for-extended-card'
190-
}
191-
_extended_card = await resolver.get_agent_card(
192-
relative_card_path=EXTENDED_AGENT_CARD_PATH,
193-
http_kwargs={'headers': auth_headers_dict},
194-
)
195-
logger.info(
196-
'Successfully fetched authenticated extended agent card:'
197-
)
198-
logger.info(
199-
_extended_card.model_dump_json(
200-
indent=2, exclude_none=True
201-
)
202-
)
203-
final_agent_card_to_use = (
204-
_extended_card
205-
)
206-
logger.info(
207-
'\nUsing AUTHENTICATED EXTENDED agent card for client initialization.'
208-
)
209-
except Exception as e_extended:
210-
logger.warning(
211-
f'Failed to fetch extended agent card: {e_extended}. Will proceed with public card.',
212-
exc_info=True,
213-
)
214-
elif (
215-
_public_card
216-
):
217-
logger.info(
218-
'\nPublic card does not indicate support for an extended card. Using public card.'
219-
)
220-
except Exception as e:
221-
logger.error(
222-
f'Critical error fetching public agent card: {e}', exc_info=True
223-
)
224-
raise RuntimeError(
225-
'Failed to fetch the public agent card. Cannot continue.'
226-
) from e
227-
client = A2AClient(
228-
httpx_client=httpx_client, agent_card=final_agent_card_to_use
229-
)
230-
logger.info('A2AClient initialized.')
231-
send_message_payload: dict[str, Any] = {
232-
'message': {
233-
'role': 'user',
234-
'parts': [
235-
{'kind': 'text', 'text': 'how much is 10 USD in INR?'}
236-
],
237-
'messageId': uuid4().hex,
238-
},
239-
}
240-
request = SendMessageRequest(
241-
id=str(uuid4()), params=MessageSendParams(**send_message_payload)
242-
)
243-
response = await client.send_message(request)
244-
print(response.model_dump(mode='json', exclude_none=True))
245-
streaming_request = SendStreamingMessageRequest(
246-
id=str(uuid4()), params=MessageSendParams(**send_message_payload)
247-
)
248-
stream_response = client.send_message_streaming(streaming_request)
249-
async for chunk in stream_response:
250-
print(chunk.model_dump(mode='json', exclude_none=True))
251154

252155
# Main Application
253156
if __name__ == '__main__':

model-deployment/A2A_agents_on_MD/agent_a/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def main() -> None:
5252
logging.basicConfig(level=logging.INFO)
5353
logger = logging.getLogger(__name__)
5454

55-
base_url = 'https://modeldeployment.us-ashburn-1.oci.customer-oci.com/ocid1.tenancy.oc1..aaaaaaaafwgqzxcwlkkpl5i334qpv62s375upsw2j4ufgcizfnnhjd4l55ia/agent-a/predict'
55+
base_url = '<add your custom url mdocid url here taken from the invoke your model screen in model deployment console>'
5656
async with httpx.AsyncClient(auth=get_auth(), verify=False, headers={"Content-Length": "0"}) as httpx_client:
5757
resolver = A2ACardResolver(
5858
httpx_client=httpx_client,

model-deployment/A2A_agents_on_MD/agent_b/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ async def __call__(self, scope, receive, send):
7373
name='Mumbai Weather Agent',
7474
description='Just a Mumbai weather agent',
7575
# url='http://localhost:9998/a2a/',
76-
# url = 'https://modeldeployment.us-ashburn-1.oci.customer-oci.com/ocid1.datasciencemodeldeployment.oc1.iad.amaaaaaay75uckqayzxhro3tqig45qhlv7lpeorfijnic3tw35dli6n6mbva/predict/a2a/',
7776
url = agent_b_url,
7877
version='1.0.0',
7978
defaultInputModes=['text'],

0 commit comments

Comments
 (0)