Spaces:
Running
Running
changing app
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ custom_css = """
|
|
21 |
"""
|
22 |
|
23 |
with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
|
24 |
-
gr.Markdown("# Medical
|
25 |
gr.Markdown("An agent that uses document retrieval and live web search to answer questions on medical transcripts.")
|
26 |
|
27 |
with gr.Row():
|
|
|
21 |
"""
|
22 |
|
23 |
with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
|
24 |
+
gr.Markdown("# Medical transcripts QA agent")
|
25 |
gr.Markdown("An agent that uses document retrieval and live web search to answer questions on medical transcripts.")
|
26 |
|
27 |
with gr.Row():
|
debug.log
CHANGED
@@ -671,3 +671,89 @@
|
|
671 |
2025-04-28 19:41:13,808 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/tokenizer_config.json HTTP/1.1" 200 0
|
672 |
2025-04-28 19:41:13,935 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "GET /api/models/sentence-transformers/all-MiniLM-L6-v2/revision/main HTTP/1.1" 200 6766
|
673 |
2025-04-28 19:41:14,051 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "GET /api/models/sentence-transformers/all-MiniLM-L6-v2 HTTP/1.1" 200 6766
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
671 |
2025-04-28 19:41:13,808 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/tokenizer_config.json HTTP/1.1" 200 0
|
672 |
2025-04-28 19:41:13,935 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "GET /api/models/sentence-transformers/all-MiniLM-L6-v2/revision/main HTTP/1.1" 200 6766
|
673 |
2025-04-28 19:41:14,051 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "GET /api/models/sentence-transformers/all-MiniLM-L6-v2 HTTP/1.1" 200 6766
|
674 |
+
2025-04-28 19:41:56,539 - asyncio - DEBUG - Using selector: KqueueSelector
|
675 |
+
2025-04-28 19:41:56,546 - httpcore.connection - DEBUG - connect_tcp.started host='api.gradio.app' port=443 local_address=None timeout=3 socket_options=None
|
676 |
+
2025-04-28 19:41:56,547 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): huggingface.co:443
|
677 |
+
2025-04-28 19:41:56,613 - httpcore.connection - DEBUG - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x14995ade0>
|
678 |
+
2025-04-28 19:41:56,613 - httpcore.connection - DEBUG - start_tls.started ssl_context=<ssl.SSLContext object at 0x14995ed50> server_hostname='api.gradio.app' timeout=3
|
679 |
+
2025-04-28 19:41:56,619 - asyncio - DEBUG - Using selector: KqueueSelector
|
680 |
+
2025-04-28 19:41:56,660 - httpcore.connection - DEBUG - connect_tcp.started host='127.0.0.1' port=7861 local_address=None timeout=None socket_options=None
|
681 |
+
2025-04-28 19:41:56,660 - httpcore.connection - DEBUG - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x15c3721b0>
|
682 |
+
2025-04-28 19:41:56,660 - httpcore.http11 - DEBUG - send_request_headers.started request=<Request [b'GET']>
|
683 |
+
2025-04-28 19:41:56,660 - httpcore.http11 - DEBUG - send_request_headers.complete
|
684 |
+
2025-04-28 19:41:56,661 - httpcore.http11 - DEBUG - send_request_body.started request=<Request [b'GET']>
|
685 |
+
2025-04-28 19:41:56,661 - httpcore.http11 - DEBUG - send_request_body.complete
|
686 |
+
2025-04-28 19:41:56,661 - httpcore.http11 - DEBUG - receive_response_headers.started request=<Request [b'GET']>
|
687 |
+
2025-04-28 19:41:56,661 - httpcore.http11 - DEBUG - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'date', b'Tue, 29 Apr 2025 02:41:56 GMT'), (b'server', b'uvicorn'), (b'content-length', b'4'), (b'content-type', b'application/json')])
|
688 |
+
2025-04-28 19:41:56,661 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7861/gradio_api/startup-events "HTTP/1.1 200 OK"
|
689 |
+
2025-04-28 19:41:56,661 - httpcore.http11 - DEBUG - receive_response_body.started request=<Request [b'GET']>
|
690 |
+
2025-04-28 19:41:56,661 - httpcore.http11 - DEBUG - receive_response_body.complete
|
691 |
+
2025-04-28 19:41:56,661 - httpcore.http11 - DEBUG - response_closed.started
|
692 |
+
2025-04-28 19:41:56,661 - httpcore.http11 - DEBUG - response_closed.complete
|
693 |
+
2025-04-28 19:41:56,662 - httpcore.connection - DEBUG - close.started
|
694 |
+
2025-04-28 19:41:56,662 - httpcore.connection - DEBUG - close.complete
|
695 |
+
2025-04-28 19:41:56,662 - httpcore.connection - DEBUG - connect_tcp.started host='127.0.0.1' port=7861 local_address=None timeout=3 socket_options=None
|
696 |
+
2025-04-28 19:41:56,662 - httpcore.connection - DEBUG - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x15c49bef0>
|
697 |
+
2025-04-28 19:41:56,662 - httpcore.http11 - DEBUG - send_request_headers.started request=<Request [b'HEAD']>
|
698 |
+
2025-04-28 19:41:56,662 - httpcore.http11 - DEBUG - send_request_headers.complete
|
699 |
+
2025-04-28 19:41:56,662 - httpcore.http11 - DEBUG - send_request_body.started request=<Request [b'HEAD']>
|
700 |
+
2025-04-28 19:41:56,662 - httpcore.http11 - DEBUG - send_request_body.complete
|
701 |
+
2025-04-28 19:41:56,662 - httpcore.http11 - DEBUG - receive_response_headers.started request=<Request [b'HEAD']>
|
702 |
+
2025-04-28 19:41:56,668 - httpcore.connection - DEBUG - start_tls.complete return_value=<httpcore._backends.sync.SyncStream object at 0x149961520>
|
703 |
+
2025-04-28 19:41:56,668 - httpcore.http11 - DEBUG - send_request_headers.started request=<Request [b'GET']>
|
704 |
+
2025-04-28 19:41:56,668 - httpcore.http11 - DEBUG - send_request_headers.complete
|
705 |
+
2025-04-28 19:41:56,668 - httpcore.http11 - DEBUG - send_request_body.started request=<Request [b'GET']>
|
706 |
+
2025-04-28 19:41:56,668 - httpcore.http11 - DEBUG - send_request_body.complete
|
707 |
+
2025-04-28 19:41:56,668 - httpcore.http11 - DEBUG - receive_response_headers.started request=<Request [b'GET']>
|
708 |
+
2025-04-28 19:41:56,671 - httpcore.http11 - DEBUG - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'date', b'Tue, 29 Apr 2025 02:41:56 GMT'), (b'server', b'uvicorn'), (b'content-length', b'11554'), (b'content-type', b'text/html; charset=utf-8')])
|
709 |
+
2025-04-28 19:41:56,671 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7861/ "HTTP/1.1 200 OK"
|
710 |
+
2025-04-28 19:41:56,671 - httpcore.http11 - DEBUG - receive_response_body.started request=<Request [b'HEAD']>
|
711 |
+
2025-04-28 19:41:56,671 - httpcore.http11 - DEBUG - receive_response_body.complete
|
712 |
+
2025-04-28 19:41:56,671 - httpcore.http11 - DEBUG - response_closed.started
|
713 |
+
2025-04-28 19:41:56,671 - httpcore.http11 - DEBUG - response_closed.complete
|
714 |
+
2025-04-28 19:41:56,671 - httpcore.connection - DEBUG - close.started
|
715 |
+
2025-04-28 19:41:56,671 - httpcore.connection - DEBUG - close.complete
|
716 |
+
2025-04-28 19:41:56,672 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): huggingface.co:443
|
717 |
+
2025-04-28 19:41:56,695 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /api/telemetry/gradio/initiated HTTP/1.1" 200 0
|
718 |
+
2025-04-28 19:41:56,699 - httpcore.http11 - DEBUG - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Date', b'Tue, 29 Apr 2025 02:41:56 GMT'), (b'Content-Type', b'application/json'), (b'Content-Length', b'21'), (b'Connection', b'keep-alive'), (b'Server', b'nginx/1.18.0'), (b'Access-Control-Allow-Origin', b'*')])
|
719 |
+
2025-04-28 19:41:56,699 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
720 |
+
2025-04-28 19:41:56,699 - httpcore.http11 - DEBUG - receive_response_body.started request=<Request [b'GET']>
|
721 |
+
2025-04-28 19:41:56,699 - httpcore.http11 - DEBUG - receive_response_body.complete
|
722 |
+
2025-04-28 19:41:56,699 - httpcore.http11 - DEBUG - response_closed.started
|
723 |
+
2025-04-28 19:41:56,699 - httpcore.http11 - DEBUG - response_closed.complete
|
724 |
+
2025-04-28 19:41:56,699 - httpcore.connection - DEBUG - close.started
|
725 |
+
2025-04-28 19:41:56,700 - httpcore.connection - DEBUG - close.complete
|
726 |
+
2025-04-28 19:41:56,771 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /api/telemetry/gradio/launched HTTP/1.1" 200 0
|
727 |
+
2025-04-28 19:42:33,611 - agent - DEBUG - Received question: what is the prognosis for hypertension for older males
|
728 |
+
2025-04-28 19:42:33,614 - anthropic._base_client - DEBUG - Request options: {'method': 'post', 'url': '/v1/messages', 'timeout': Timeout(connect=5.0, read=600, write=600, pool=600), 'files': None, 'idempotency_key': 'stainless-python-retry-26d19282-8157-40a5-a63d-8e52b636cdc2', 'json_data': {'max_tokens': 500, 'messages': [{'role': 'user', 'content': 'Question: "Decide which tool(s) are needed to answer this question: "what is the prognosis for hypertension for older males".\n Available tools:\n - Document RAG (for clinical facts)\n - Search (for public info)\n\n Reply in format:\n TOOL: [Document/Search/Both/All]\n "\n\nDecide the best tool for answering it. Reply exactly with TOOL: [Document], TOOL: [Search], or TOOL: [Both]. No other text.'}], 'model': 'claude-3-7-sonnet-20250219', 'system': 'You are an expert clinical AI assistant. You must strictly reply in ONLY one of the following formats: TOOL: [Document], TOOL: [Search], or TOOL: [Both].\n\nFor questions about general medical information like recovery times, procedure durations, or standard practices, prefer TOOL: [Search].\nFor questions about specific medical cases or rare conditions found in the document database, use TOOL: [Document].\nFor questions that would benefit from both sources, use TOOL: [Both].\n\nNever explain, never say anything else.', 'temperature': 0}}
|
729 |
+
2025-04-28 19:42:33,653 - anthropic._base_client - DEBUG - Sending HTTP Request: POST https://api.anthropic.com/v1/messages
|
730 |
+
2025-04-28 19:42:33,653 - httpcore.connection - DEBUG - connect_tcp.started host='api.anthropic.com' port=443 local_address=None timeout=5.0 socket_options=[(65535, 8, True), (6, 257, 60), (6, 258, 5)]
|
731 |
+
2025-04-28 19:42:33,673 - httpcore.connection - DEBUG - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x15c83cbf0>
|
732 |
+
2025-04-28 19:42:33,673 - httpcore.connection - DEBUG - start_tls.started ssl_context=<ssl.SSLContext object at 0x1489b2f50> server_hostname='api.anthropic.com' timeout=5.0
|
733 |
+
2025-04-28 19:42:33,690 - httpcore.connection - DEBUG - start_tls.complete return_value=<httpcore._backends.sync.SyncStream object at 0x15c806510>
|
734 |
+
2025-04-28 19:42:33,690 - httpcore.http11 - DEBUG - send_request_headers.started request=<Request [b'POST']>
|
735 |
+
2025-04-28 19:42:33,690 - httpcore.http11 - DEBUG - send_request_headers.complete
|
736 |
+
2025-04-28 19:42:33,690 - httpcore.http11 - DEBUG - send_request_body.started request=<Request [b'POST']>
|
737 |
+
2025-04-28 19:42:33,690 - httpcore.http11 - DEBUG - send_request_body.complete
|
738 |
+
2025-04-28 19:42:33,690 - httpcore.http11 - DEBUG - receive_response_headers.started request=<Request [b'POST']>
|
739 |
+
2025-04-28 19:42:35,992 - httpcore.http11 - DEBUG - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Date', b'Tue, 29 Apr 2025 02:42:35 GMT'), (b'Content-Type', b'application/json'), (b'Transfer-Encoding', b'chunked'), (b'Connection', b'keep-alive'), (b'anthropic-ratelimit-input-tokens-limit', b'20000'), (b'anthropic-ratelimit-input-tokens-remaining', b'20000'), (b'anthropic-ratelimit-input-tokens-reset', b'2025-04-29T02:42:35Z'), (b'anthropic-ratelimit-output-tokens-limit', b'8000'), (b'anthropic-ratelimit-output-tokens-remaining', b'8000'), (b'anthropic-ratelimit-output-tokens-reset', b'2025-04-29T02:42:35Z'), (b'anthropic-ratelimit-requests-limit', b'50'), (b'anthropic-ratelimit-requests-remaining', b'49'), (b'anthropic-ratelimit-requests-reset', b'2025-04-29T02:42:34Z'), (b'anthropic-ratelimit-tokens-limit', b'28000'), (b'anthropic-ratelimit-tokens-remaining', b'28000'), (b'anthropic-ratelimit-tokens-reset', b'2025-04-29T02:42:35Z'), (b'request-id', b'req_011CNcFey1tnUp98rDwGFaod'), (b'anthropic-organization-id', b'961c62a8-661b-402f-b3ec-38f150bfa917'), (b'via', b'1.1 google'), (b'cf-cache-status', b'DYNAMIC'), (b'X-Robots-Tag', b'none'), (b'Server', b'cloudflare'), (b'CF-RAY', b'937b7260ab932512-SJC'), (b'Content-Encoding', b'gzip')])
|
740 |
+
2025-04-28 19:42:35,994 - httpx - INFO - HTTP Request: POST https://api.anthropic.com/v1/messages "HTTP/1.1 200 OK"
|
741 |
+
2025-04-28 19:42:35,995 - httpcore.http11 - DEBUG - receive_response_body.started request=<Request [b'POST']>
|
742 |
+
2025-04-28 19:42:35,997 - httpcore.http11 - DEBUG - receive_response_body.complete
|
743 |
+
2025-04-28 19:42:35,998 - httpcore.http11 - DEBUG - response_closed.started
|
744 |
+
2025-04-28 19:42:35,998 - httpcore.http11 - DEBUG - response_closed.complete
|
745 |
+
2025-04-28 19:42:35,999 - anthropic._base_client - DEBUG - HTTP Response: POST https://api.anthropic.com/v1/messages "200 OK" Headers({'date': 'Tue, 29 Apr 2025 02:42:35 GMT', 'content-type': 'application/json', 'transfer-encoding': 'chunked', 'connection': 'keep-alive', 'anthropic-ratelimit-input-tokens-limit': '20000', 'anthropic-ratelimit-input-tokens-remaining': '20000', 'anthropic-ratelimit-input-tokens-reset': '2025-04-29T02:42:35Z', 'anthropic-ratelimit-output-tokens-limit': '8000', 'anthropic-ratelimit-output-tokens-remaining': '8000', 'anthropic-ratelimit-output-tokens-reset': '2025-04-29T02:42:35Z', 'anthropic-ratelimit-requests-limit': '50', 'anthropic-ratelimit-requests-remaining': '49', 'anthropic-ratelimit-requests-reset': '2025-04-29T02:42:34Z', 'anthropic-ratelimit-tokens-limit': '28000', 'anthropic-ratelimit-tokens-remaining': '28000', 'anthropic-ratelimit-tokens-reset': '2025-04-29T02:42:35Z', 'request-id': 'req_011CNcFey1tnUp98rDwGFaod', 'anthropic-organization-id': '961c62a8-661b-402f-b3ec-38f150bfa917', 'via': '1.1 google', 'cf-cache-status': 'DYNAMIC', 'x-robots-tag': 'none', 'server': 'cloudflare', 'cf-ray': '937b7260ab932512-SJC', 'content-encoding': 'gzip'})
|
746 |
+
2025-04-28 19:42:36,000 - anthropic._base_client - DEBUG - request_id: req_011CNcFey1tnUp98rDwGFaod
|
747 |
+
2025-04-28 19:42:36,010 - agent - DEBUG - Tool decision raw response: 'TOOL: [Search]'
|
748 |
+
2025-04-28 19:42:36,010 - agent - DEBUG - Parsed decision - Use Document: False, Use Search: True
|
749 |
+
2025-04-28 19:42:36,011 - agent - DEBUG - Searching web...
|
750 |
+
2025-04-28 19:42:36,024 - primp.utils - DEBUG - Loaded CA certs
|
751 |
+
2025-04-28 19:42:36,029 - rquest.connect - DEBUG - starting new connection: https://lite.duckduckgo.com/
|
752 |
+
2025-04-28 19:42:36,029 - rquest.util.client.connect.dns - DEBUG - resolving lite.duckduckgo.com
|
753 |
+
2025-04-28 19:42:36,051 - rquest.util.client.connect.http - DEBUG - connecting to 52.250.42.157:443
|
754 |
+
2025-04-28 19:42:36,080 - rquest.util.client.connect.http - DEBUG - connected to 52.250.42.157:443
|
755 |
+
2025-04-28 19:42:36,114 - rquest.util.client.pool - DEBUG - pooling idle connection for PoolKey { uri: https://lite.duckduckgo.com/, alpn_protos: None, network: default }
|
756 |
+
2025-04-28 19:42:37,220 - cookie_store.cookie_store - DEBUG - inserting secure cookie 'kl'
|
757 |
+
2025-04-28 19:42:37,221 - primp - INFO - response: https://lite.duckduckgo.com/lite/ 200
|
758 |
+
2025-04-28 19:42:37,222 - duckduckgo_search.DDGS - DEBUG - _get_url() https://lite.duckduckgo.com/lite/ 200
|
759 |
+
2025-04-28 19:42:37,232 - agent - DEBUG - Search returned 1523 characters
|