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.2.tar.gz (18.1 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.2-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hospital_agent_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 18.1 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.2.tar.gz
Algorithm Hash digest
SHA256 cc3747e37d27db6c0ce869b97d96f2f26b2636e712d0400e8a875230227f53f2
MD5 15584ab376e346981cd4ab76fde28c1a
BLAKE2b-256 7216901b2d41beaed83ba5146db42dca561f7dba4146545343c6abbfef83c44b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hospital_agent_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ab00e8bf0f4b6363f39359d4109ea67ac3bab1e7b93271bf47a6ef0f6ef2a620
MD5 cf420361bc0b00738d557e8da2f89628
BLAKE2b-256 e78aaea244e6aba52e20c5bb992e8146f24b942b46856d9417a8d56471cb536d

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