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.2.1.tar.gz (18.2 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.2.1-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hospital_agent_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 18.2 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.2.1.tar.gz
Algorithm Hash digest
SHA256 175148a8834b5e0eadadf13a378bc55d90d42d97a39e8dc400d73623e8fa7dcf
MD5 bea92d267456799a321d3eb68c537af4
BLAKE2b-256 b38a6caf9c7c7fe5d63245fccf2b9d479619c9171369f7584cf709dae39c16e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hospital_agent_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 07d5e17c014e169184735dde85d56400c275750fbb5a4640771bc68282ce8cbb
MD5 bf5a20b5b7b0903fe835a44aa4393f65
BLAKE2b-256 f543d7473480da9d2c9f71c7d246c6ffb732c6e43dde0dc4fbbedc5a906a3030

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