File size: 2,481 Bytes
38ca196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2aea50e4-af9b-419c-afd4-733b8ce5f1be",
   "metadata": {},
   "outputs": [],
   "source": [
    "#| default_exp main"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9eca9cd0-fe04-4c4f-b434-1e9106bff73c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# | export\n",
    "\"\"\"Main entry point for the WardBuddy application.\"\"\"\n",
    "import asyncio\n",
    "from pathlib import Path\n",
    "import typer\n",
    "from typing import Optional\n",
    "import logging\n",
    "\n",
    "from wardbuddy.learning_interface import LearningInterface\n",
    "\n",
    "# Configure logging\n",
    "logging.basicConfig(level=logging.INFO)\n",
    "logger = logging.getLogger(__name__)\n",
    "\n",
    "app = typer.Typer()\n",
    "\n",
    "@app.command()\n",
    "def launch(\n",
    "    port: int = typer.Option(7860, help=\"Port to run on\"),\n",
    "    context_path: Optional[Path] = typer.Option(\n",
    "        None,\n",
    "        help=\"Path to context file\",\n",
    "        dir_okay=False\n",
    "    ),\n",
    "    model: str = typer.Option(\n",
    "        \"anthropic/claude-3-sonnet\",\n",
    "        help=\"OpenRouter model identifier\"\n",
    "    ),\n",
    "    share: bool = typer.Option(\n",
    "        False,\n",
    "        help=\"Create public URL\"\n",
    "    )\n",
    ") -> None:\n",
    "    \"\"\"Launch the clinical learning interface.\"\"\"\n",
    "    try:\n",
    "        interface = LearningInterface(\n",
    "            context_path=context_path,\n",
    "            model=model\n",
    "        )\n",
    "        \n",
    "        app = interface.create_interface()\n",
    "        app.launch(\n",
    "            server_port=port,\n",
    "            share=share\n",
    "        )\n",
    "        \n",
    "        logger.info(f\"Interface launched on port {port}\")\n",
    "        \n",
    "    except Exception as e:\n",
    "        logger.error(f\"Error launching interface: {str(e)}\")\n",
    "        raise typer.Exit(1)\n",
    "\n",
    "def run_app():\n",
    "    \"\"\"Entry point for command line.\"\"\"\n",
    "    app()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "python3",
   "language": "python",
   "name": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}