atrmkj commited on
Commit
3e24c7a
·
1 Parent(s): 69ba259

changing gradio app

Browse files
.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ .DS_Store
2
+ __pycache__/agent.cpython-312.pyc
3
+ tools/__pycache__/retriever_tool.cpython-312.pyc
4
+ tools/__pycache__/search_tool.cpython-312.pyc
5
+ __pycache__/agent.cpython-312.pyc
README.md CHANGED
@@ -8,7 +8,7 @@ sdk_version: 5.27.1
8
  app_file: app.py
9
  pinned: false
10
  ---
11
- # Healthcare Tool-Using AI Agent
12
 
13
  A medical Q&A system that intelligently routes queries between document retrieval and web search to provide accurate healthcare information.
14
 
@@ -32,14 +32,14 @@ The agent makes intelligent decisions about which tool to use based on the query
32
 
33
  1. Clone the repository:
34
  ```bash
35
- git clone https://github.com/yourusername/healthcare-tool-agent.git
36
- cd healthcare-tool-agent
37
  ```
38
 
39
  2. Create a virtual environment and install dependencies:
40
  ```bash
41
  python -m venv venv
42
- source venv/bin/activate # On Windows: venv\Scripts\activate
43
  pip install -r requirements.txt
44
  ```
45
 
 
8
  app_file: app.py
9
  pinned: false
10
  ---
11
+ # MedTranscript QA Agent
12
 
13
  A medical Q&A system that intelligently routes queries between document retrieval and web search to provide accurate healthcare information.
14
 
 
32
 
33
  1. Clone the repository:
34
  ```bash
35
+ git clone https://github.com/atreyee-m/medTranscript_QA_agent.git
36
+ cd medTranscript_QA_agent
37
  ```
38
 
39
  2. Create a virtual environment and install dependencies:
40
  ```bash
41
  python -m venv venv
42
+ source venv/bin/activate
43
  pip install -r requirements.txt
44
  ```
45
 
__pycache__/agent.cpython-312.pyc CHANGED
Binary files a/__pycache__/agent.cpython-312.pyc and b/__pycache__/agent.cpython-312.pyc differ
 
app.py CHANGED
@@ -21,8 +21,8 @@ custom_css = """
21
  """
22
 
23
  with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
24
- gr.Markdown("# Healthcare Tool-Using AI Agent")
25
- gr.Markdown("An agent that uses document retrieval, live web search, and calculation to answer clinical healthcare questions.")
26
 
27
  with gr.Row():
28
  with gr.Column(scale=1):
 
21
  """
22
 
23
  with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
24
+ gr.Markdown("# Medical transcription 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():
28
  with gr.Column(scale=1):
debug.log CHANGED
@@ -558,3 +558,103 @@
558
  2025-04-27 21:43:33,514 - agent - DEBUG - Search returned 1530 characters
559
  2025-04-27 21:45:15,027 - httpcore.connection - DEBUG - close.started
560
  2025-04-27 21:45:15,028 - httpcore.connection - DEBUG - close.complete
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
558
  2025-04-27 21:43:33,514 - agent - DEBUG - Search returned 1530 characters
559
  2025-04-27 21:45:15,027 - httpcore.connection - DEBUG - close.started
560
  2025-04-27 21:45:15,028 - httpcore.connection - DEBUG - close.complete
561
+ 2025-04-28 19:18:08,882 - sentence_transformers.SentenceTransformer - INFO - Use pytorch device_name: mps
562
+ 2025-04-28 19:18:08,882 - sentence_transformers.SentenceTransformer - INFO - Load pretrained SentenceTransformer: all-MiniLM-L6-v2
563
+ 2025-04-28 19:18:08,885 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): huggingface.co:443
564
+ 2025-04-28 19:18:09,034 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/modules.json HTTP/1.1" 200 0
565
+ 2025-04-28 19:18:09,127 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/config_sentence_transformers.json HTTP/1.1" 200 0
566
+ 2025-04-28 19:18:09,235 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/README.md HTTP/1.1" 200 0
567
+ 2025-04-28 19:18:09,339 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/modules.json HTTP/1.1" 200 0
568
+ 2025-04-28 19:18:09,435 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/sentence_bert_config.json HTTP/1.1" 200 0
569
+ 2025-04-28 19:18:09,535 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/adapter_config.json HTTP/1.1" 404 0
570
+ 2025-04-28 19:18:09,631 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/config.json HTTP/1.1" 200 0
571
+ 2025-04-28 19:18:09,931 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /sentence-transformers/all-MiniLM-L6-v2/resolve/main/tokenizer_config.json HTTP/1.1" 200 0
572
+ 2025-04-28 19:18:10,053 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "GET /api/models/sentence-transformers/all-MiniLM-L6-v2/revision/main HTTP/1.1" 200 6766
573
+ 2025-04-28 19:18:10,179 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "GET /api/models/sentence-transformers/all-MiniLM-L6-v2 HTTP/1.1" 200 6766
574
+ 2025-04-28 19:18:53,331 - asyncio - DEBUG - Using selector: KqueueSelector
575
+ 2025-04-28 19:18:53,331 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): huggingface.co:443
576
+ 2025-04-28 19:18:53,353 - httpcore.connection - DEBUG - connect_tcp.started host='api.gradio.app' port=443 local_address=None timeout=3 socket_options=None
577
+ 2025-04-28 19:18:53,411 - httpcore.connection - DEBUG - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x116fa1bb0>
578
+ 2025-04-28 19:18:53,412 - httpcore.connection - DEBUG - start_tls.started ssl_context=<ssl.SSLContext object at 0x116d85fd0> server_hostname='api.gradio.app' timeout=3
579
+ 2025-04-28 19:18:53,422 - asyncio - DEBUG - Using selector: KqueueSelector
580
+ 2025-04-28 19:18:53,456 - httpcore.connection - DEBUG - connect_tcp.started host='127.0.0.1' port=7861 local_address=None timeout=None socket_options=None
581
+ 2025-04-28 19:18:53,456 - httpcore.connection - DEBUG - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x13fbdf230>
582
+ 2025-04-28 19:18:53,457 - httpcore.http11 - DEBUG - send_request_headers.started request=<Request [b'GET']>
583
+ 2025-04-28 19:18:53,457 - httpcore.http11 - DEBUG - send_request_headers.complete
584
+ 2025-04-28 19:18:53,457 - httpcore.http11 - DEBUG - send_request_body.started request=<Request [b'GET']>
585
+ 2025-04-28 19:18:53,457 - httpcore.http11 - DEBUG - send_request_body.complete
586
+ 2025-04-28 19:18:53,458 - httpcore.http11 - DEBUG - receive_response_headers.started request=<Request [b'GET']>
587
+ 2025-04-28 19:18:53,458 - httpcore.http11 - DEBUG - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'date', b'Tue, 29 Apr 2025 02:18:53 GMT'), (b'server', b'uvicorn'), (b'content-length', b'4'), (b'content-type', b'application/json')])
588
+ 2025-04-28 19:18:53,458 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7861/gradio_api/startup-events "HTTP/1.1 200 OK"
589
+ 2025-04-28 19:18:53,458 - httpcore.http11 - DEBUG - receive_response_body.started request=<Request [b'GET']>
590
+ 2025-04-28 19:18:53,458 - httpcore.http11 - DEBUG - receive_response_body.complete
591
+ 2025-04-28 19:18:53,458 - httpcore.http11 - DEBUG - response_closed.started
592
+ 2025-04-28 19:18:53,458 - httpcore.http11 - DEBUG - response_closed.complete
593
+ 2025-04-28 19:18:53,458 - httpcore.connection - DEBUG - close.started
594
+ 2025-04-28 19:18:53,458 - httpcore.connection - DEBUG - close.complete
595
+ 2025-04-28 19:18:53,458 - httpcore.connection - DEBUG - connect_tcp.started host='127.0.0.1' port=7861 local_address=None timeout=3 socket_options=None
596
+ 2025-04-28 19:18:53,458 - httpcore.connection - DEBUG - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x13fbdf350>
597
+ 2025-04-28 19:18:53,459 - httpcore.http11 - DEBUG - send_request_headers.started request=<Request [b'HEAD']>
598
+ 2025-04-28 19:18:53,459 - httpcore.http11 - DEBUG - send_request_headers.complete
599
+ 2025-04-28 19:18:53,459 - httpcore.http11 - DEBUG - send_request_body.started request=<Request [b'HEAD']>
600
+ 2025-04-28 19:18:53,459 - httpcore.http11 - DEBUG - send_request_body.complete
601
+ 2025-04-28 19:18:53,459 - httpcore.http11 - DEBUG - receive_response_headers.started request=<Request [b'HEAD']>
602
+ 2025-04-28 19:18:53,464 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /api/telemetry/gradio/initiated HTTP/1.1" 200 0
603
+ 2025-04-28 19:18:53,466 - httpcore.http11 - DEBUG - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'date', b'Tue, 29 Apr 2025 02:18:53 GMT'), (b'server', b'uvicorn'), (b'content-length', b'11567'), (b'content-type', b'text/html; charset=utf-8')])
604
+ 2025-04-28 19:18:53,466 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7861/ "HTTP/1.1 200 OK"
605
+ 2025-04-28 19:18:53,466 - httpcore.http11 - DEBUG - receive_response_body.started request=<Request [b'HEAD']>
606
+ 2025-04-28 19:18:53,466 - httpcore.http11 - DEBUG - receive_response_body.complete
607
+ 2025-04-28 19:18:53,466 - httpcore.http11 - DEBUG - response_closed.started
608
+ 2025-04-28 19:18:53,466 - httpcore.http11 - DEBUG - response_closed.complete
609
+ 2025-04-28 19:18:53,467 - httpcore.connection - DEBUG - close.started
610
+ 2025-04-28 19:18:53,467 - httpcore.connection - DEBUG - close.complete
611
+ 2025-04-28 19:18:53,467 - httpcore.connection - DEBUG - start_tls.complete return_value=<httpcore._backends.sync.SyncStream object at 0x116e5b260>
612
+ 2025-04-28 19:18:53,467 - httpcore.http11 - DEBUG - send_request_headers.started request=<Request [b'GET']>
613
+ 2025-04-28 19:18:53,467 - httpcore.http11 - DEBUG - send_request_headers.complete
614
+ 2025-04-28 19:18:53,467 - httpcore.http11 - DEBUG - send_request_body.started request=<Request [b'GET']>
615
+ 2025-04-28 19:18:53,467 - httpcore.http11 - DEBUG - send_request_body.complete
616
+ 2025-04-28 19:18:53,467 - httpcore.http11 - DEBUG - receive_response_headers.started request=<Request [b'GET']>
617
+ 2025-04-28 19:18:53,495 - httpcore.http11 - DEBUG - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Date', b'Tue, 29 Apr 2025 02:18:53 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'*')])
618
+ 2025-04-28 19:18:53,495 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
619
+ 2025-04-28 19:18:53,495 - httpcore.http11 - DEBUG - receive_response_body.started request=<Request [b'GET']>
620
+ 2025-04-28 19:18:53,495 - httpcore.http11 - DEBUG - receive_response_body.complete
621
+ 2025-04-28 19:18:53,495 - httpcore.http11 - DEBUG - response_closed.started
622
+ 2025-04-28 19:18:53,495 - httpcore.http11 - DEBUG - response_closed.complete
623
+ 2025-04-28 19:18:53,495 - httpcore.connection - DEBUG - close.started
624
+ 2025-04-28 19:18:53,495 - httpcore.connection - DEBUG - close.complete
625
+ 2025-04-28 19:18:53,558 - urllib3.connectionpool - DEBUG - https://huggingface.co:443 "HEAD /api/telemetry/gradio/launched HTTP/1.1" 200 0
626
+ 2025-04-28 19:20:18,296 - agent - DEBUG - Received question: what is the typical age for hypertension
627
+ 2025-04-28 19:20:18,298 - 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-af9024fe-1c7f-4541-bc47-aee60e93a390', 'json_data': {'max_tokens': 500, 'messages': [{'role': 'user', 'content': 'Question: "Decide which tool(s) are needed to answer this question: "what is the typical age for hypertension".\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}}
628
+ 2025-04-28 19:20:18,343 - anthropic._base_client - DEBUG - Sending HTTP Request: POST https://api.anthropic.com/v1/messages
629
+ 2025-04-28 19:20:18,343 - 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)]
630
+ 2025-04-28 19:20:18,361 - httpcore.connection - DEBUG - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x13fe4a5a0>
631
+ 2025-04-28 19:20:18,361 - httpcore.connection - DEBUG - start_tls.started ssl_context=<ssl.SSLContext object at 0x108a30d50> server_hostname='api.anthropic.com' timeout=5.0
632
+ 2025-04-28 19:20:18,379 - httpcore.connection - DEBUG - start_tls.complete return_value=<httpcore._backends.sync.SyncStream object at 0x13fe4b9e0>
633
+ 2025-04-28 19:20:18,379 - httpcore.http11 - DEBUG - send_request_headers.started request=<Request [b'POST']>
634
+ 2025-04-28 19:20:18,380 - httpcore.http11 - DEBUG - send_request_headers.complete
635
+ 2025-04-28 19:20:18,380 - httpcore.http11 - DEBUG - send_request_body.started request=<Request [b'POST']>
636
+ 2025-04-28 19:20:18,380 - httpcore.http11 - DEBUG - send_request_body.complete
637
+ 2025-04-28 19:20:18,380 - httpcore.http11 - DEBUG - receive_response_headers.started request=<Request [b'POST']>
638
+ 2025-04-28 19:20:20,070 - httpcore.http11 - DEBUG - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Date', b'Tue, 29 Apr 2025 02:20:20 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:20:19Z'), (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:20:19Z'), (b'anthropic-ratelimit-requests-limit', b'50'), (b'anthropic-ratelimit-requests-remaining', b'49'), (b'anthropic-ratelimit-requests-reset', b'2025-04-29T02:20:19Z'), (b'anthropic-ratelimit-tokens-limit', b'28000'), (b'anthropic-ratelimit-tokens-remaining', b'28000'), (b'anthropic-ratelimit-tokens-reset', b'2025-04-29T02:20:19Z'), (b'request-id', b'req_011CNcDxY2VoYyx9q7zwABMo'), (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'937b51c6ff5b230c-SJC'), (b'Content-Encoding', b'gzip')])
639
+ 2025-04-28 19:20:20,072 - httpx - INFO - HTTP Request: POST https://api.anthropic.com/v1/messages "HTTP/1.1 200 OK"
640
+ 2025-04-28 19:20:20,074 - httpcore.http11 - DEBUG - receive_response_body.started request=<Request [b'POST']>
641
+ 2025-04-28 19:20:20,077 - httpcore.http11 - DEBUG - receive_response_body.complete
642
+ 2025-04-28 19:20:20,077 - httpcore.http11 - DEBUG - response_closed.started
643
+ 2025-04-28 19:20:20,078 - httpcore.http11 - DEBUG - response_closed.complete
644
+ 2025-04-28 19:20:20,078 - anthropic._base_client - DEBUG - HTTP Response: POST https://api.anthropic.com/v1/messages "200 OK" Headers({'date': 'Tue, 29 Apr 2025 02:20:20 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:20:19Z', 'anthropic-ratelimit-output-tokens-limit': '8000', 'anthropic-ratelimit-output-tokens-remaining': '8000', 'anthropic-ratelimit-output-tokens-reset': '2025-04-29T02:20:19Z', 'anthropic-ratelimit-requests-limit': '50', 'anthropic-ratelimit-requests-remaining': '49', 'anthropic-ratelimit-requests-reset': '2025-04-29T02:20:19Z', 'anthropic-ratelimit-tokens-limit': '28000', 'anthropic-ratelimit-tokens-remaining': '28000', 'anthropic-ratelimit-tokens-reset': '2025-04-29T02:20:19Z', 'request-id': 'req_011CNcDxY2VoYyx9q7zwABMo', 'anthropic-organization-id': '961c62a8-661b-402f-b3ec-38f150bfa917', 'via': '1.1 google', 'cf-cache-status': 'DYNAMIC', 'x-robots-tag': 'none', 'server': 'cloudflare', 'cf-ray': '937b51c6ff5b230c-SJC', 'content-encoding': 'gzip'})
645
+ 2025-04-28 19:20:20,078 - anthropic._base_client - DEBUG - request_id: req_011CNcDxY2VoYyx9q7zwABMo
646
+ 2025-04-28 19:20:20,101 - agent - DEBUG - Tool decision raw response: 'TOOL: [Search]'
647
+ 2025-04-28 19:20:20,101 - agent - DEBUG - Parsed decision - Use Document: False, Use Search: True
648
+ 2025-04-28 19:20:20,101 - agent - DEBUG - Searching web...
649
+ 2025-04-28 19:20:20,111 - primp.utils - DEBUG - Loaded CA certs
650
+ 2025-04-28 19:20:20,115 - rquest.connect - DEBUG - starting new connection: https://html.duckduckgo.com/
651
+ 2025-04-28 19:20:20,115 - rquest.util.client.connect.dns - DEBUG - resolving html.duckduckgo.com
652
+ 2025-04-28 19:20:20,126 - rquest.util.client.connect.http - DEBUG - connecting to 52.250.42.157:443
653
+ 2025-04-28 19:20:20,154 - rquest.util.client.connect.http - DEBUG - connected to 52.250.42.157:443
654
+ 2025-04-28 19:20:20,198 - rquest.util.client.pool - DEBUG - pooling idle connection for PoolKey { uri: https://html.duckduckgo.com/, alpn_protos: None, network: default }
655
+ 2025-04-28 19:20:21,196 - cookie_store.cookie_store - DEBUG - inserting secure cookie 'kl'
656
+ 2025-04-28 19:20:21,197 - primp - INFO - response: https://html.duckduckgo.com/html 200
657
+ 2025-04-28 19:20:21,197 - duckduckgo_search.DDGS - DEBUG - _get_url() https://html.duckduckgo.com/html 200
658
+ 2025-04-28 19:20:21,207 - agent - DEBUG - Search returned 1532 characters
659
+ 2025-04-28 19:33:38,312 - httpcore.connection - DEBUG - close.started
660
+ 2025-04-28 19:33:38,314 - httpcore.connection - DEBUG - close.complete
tools/__pycache__/retriever_tool.cpython-312.pyc CHANGED
Binary files a/tools/__pycache__/retriever_tool.cpython-312.pyc and b/tools/__pycache__/retriever_tool.cpython-312.pyc differ
 
tools/__pycache__/search_tool.cpython-312.pyc CHANGED
Binary files a/tools/__pycache__/search_tool.cpython-312.pyc and b/tools/__pycache__/search_tool.cpython-312.pyc differ
 
tools/requirements.txt DELETED
@@ -1,9 +0,0 @@
1
- openai
2
- requests
3
- python-dotenv
4
- faiss-cpu
5
- sentence-transformers
6
- pandas
7
- duckduckgo_search
8
- gradio
9
- anthropic