Skip to main content

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 中配置输出目录和训练参数,并通过环境变量提供比赛服务地址、ModelScope SDK Token、训练 token、模型 API Key 和队伍 ID。

调用 ModelScope API 专用地址时需要配置以下变量:

export SERVICE_BASE_URL=https://studio-baconroot-hospital-service.api-inference.modelscope.net
export MODELSCOPE_SDK_TOKEN=<your-own-modelscope-sdk-token>
export SERVICE_TRAIN_TOKEN=<your-train-service-token>
export MODEL_API_KEY=<your-model-api-key>
export TEAM_ID=<your-team-id>

MODELSCOPE_SDK_TOKEN 必须使用运行该 Agent 的选手自己的 ModelScope SDK Token。

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: hospital_agent_sdk-0.2.2.tar.gz
  • Upload date:
  • Size: 21.0 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.2.tar.gz
Algorithm Hash digest
SHA256 7982677be9df6453152c7f92c62969dd4e22fe645667797e2f30fd52da1253fa
MD5 e40d56e237eb9a82ab1138d09f73b909
BLAKE2b-256 0ff05b1600116c5545314b09fdc1b060d8a8503774d9889f4410edabaf0ee740

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hospital_agent_sdk-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c181d8a057682f62f4172a24af8c32fb945f64b2ceba702badce034b83ce577d
MD5 5c81c6ef3e42db58e2fc569687450e84
BLAKE2b-256 c99128b8d03defab6a1c0f6bf5164e8c471035a9ad0d857aa7ee422c65240973

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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