Skip to main content

SDK for building OpenHospital contest doctor agents.

Project description

Hospital Agent SDK

hospital_agent_sdk 是虚拟诊疗比赛使用的 Python SDK,用于帮助参赛队伍快速编写医生 Agent,并对接比赛提供的患者、检查、诊断、治疗和评测服务。

主要文件说明:

  • agent.py:定义基础医生 Agent 类,参赛者可以继承它实现自己的训练和测试逻辑。
  • actions.py:封装医生可执行的主要操作,如询问患者、申请检查、给出诊断和制定治疗方案。
  • client.py:负责和比赛后端服务通信,获取患者信息、调用接口和提交结果。
  • llm.py:封装大模型调用逻辑,供 Agent 在诊疗过程中使用。
  • runtime.py / builder.py:负责加载配置、初始化运行环境,并启动训练或测试流程。
  • server.py:提供测试阶段使用的 Flask 服务入口。
  • event_logger.py:记录诊疗过程和运行结果,便于后续分析。

参赛项目通常只需要在自己的 agent.pytrain.pymemory.py 中编写业务逻辑,并通过本 SDK 调用比赛相关能力。

用法

参赛者可以继承 SDK 提供的 BasicAgent,在自己的 Agent 中实现 traintest 方法,并通过 self.actions 调用询问患者、申请检查、诊断和治疗等能力。训练阶段可以在本地脚本中直接运行 Agent,测试阶段则通过 SDK 提供的服务入口对接比赛平台。

Quick Start

安装 SDK:

pip install hospital-agent-sdk

在项目代码中使用:

from hospital_agent_sdk import BasicAgent, AgentBuilder, load_config


class MyDoctorAgent(BasicAgent):
    async def train(self, patient_id: str):
        return await self.actions.prescribe_treatment(
            patient_id=patient_id,
            diagnosis=["待完善诊断"],
            treatment_plan="待完善治疗方案",
            reasoning="待完善推理过程",
        )

    async def test(self, patient_id: str):
        return await self.train(patient_id)


config = load_config("config.yaml")
agent = MyDoctorAgent(config=config)
AgentBuilder(agent).start()

本地运行前通常需要在 config.yaml 中配置输出目录和训练参数,并通过环境变量提供比赛服务地址、训练 token、模型 API Key 和队伍 ID。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hospital_agent_sdk-0.1.3.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hospital_agent_sdk-0.1.3-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file hospital_agent_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: hospital_agent_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for hospital_agent_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5e56f184e15eec7086a2c4fa9b46a8b66bc8643c4bd3ea3f00a24333726b89d9
MD5 17de60d321bf2760bb7ac71f5cdc1f4e
BLAKE2b-256 b022d5e686c11f725627829b877fe43f5f295538a9de02a49e06310c47657d35

See more details on using hashes here.

File details

Details for the file hospital_agent_sdk-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for hospital_agent_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 26dfe62841d6c4177c77620b0af0f6d32ae98178487eea7f443d46cb84ffa80b
MD5 35b66d1380b6bed7ecd281cdaaf29603
BLAKE2b-256 be9e606e9319831522c1f27ca8f87145529ff1ba6475166299baf760d5fba94e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page