{"id":31468175,"url":"https://github.com/bingowon/giant_big","last_synced_at":"2025-10-01T19:55:17.112Z","repository":{"id":317573077,"uuid":"1067991984","full_name":"BingoWon/giant_big","owner":"BingoWon","description":"OpenAI-Compatible API Server for Apple Intelligence - Structured Output, Streaming, Multi-turn Conversations","archived":false,"fork":false,"pushed_at":"2025-10-01T17:48:42.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-01T19:26:32.744Z","etag":null,"topics":["api-server","apple-intelligence","foundation-models","json-schema","macos","openai-api","structured-output","swift","swiftui"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BingoWon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-01T17:31:50.000Z","updated_at":"2025-10-01T17:48:46.000Z","dependencies_parsed_at":"2025-10-01T19:26:35.172Z","dependency_job_id":null,"html_url":"https://github.com/BingoWon/giant_big","commit_stats":null,"previous_names":["bingowon/giant_big"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/BingoWon/giant_big","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BingoWon%2Fgiant_big","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BingoWon%2Fgiant_big/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BingoWon%2Fgiant_big/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BingoWon%2Fgiant_big/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BingoWon","download_url":"https://codeload.github.com/BingoWon/giant_big/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BingoWon%2Fgiant_big/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277900424,"owners_count":25896988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-01T02:00:09.286Z","response_time":88,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-server","apple-intelligence","foundation-models","json-schema","macos","openai-api","structured-output","swift","swiftui"],"created_at":"2025-10-01T19:55:12.076Z","updated_at":"2025-10-01T19:55:17.107Z","avatar_url":"https://github.com/BingoWon.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Giant Big\n\n**OpenAI-Compatible API Server for Apple Intelligence**\n\nA modern macOS application that wraps Apple's Foundation Models (Apple Intelligence) as an OpenAI-compatible HTTP API server, enabling seamless integration with existing OpenAI client libraries and tools.\n\n## Features\n\n- ✅ **OpenAI API Compatible** - Drop-in replacement for OpenAI API\n- ✅ **Structured Output** - Full JSON Schema support with runtime validation\n- ✅ **Streaming Support** - Server-Sent Events (SSE) for real-time responses\n- ✅ **Multi-turn Conversations** - Stateful session management with Transcript\n- ✅ **Type-Safe** - Built with Swift 6 concurrency and Sendable protocols\n- ✅ **Modern SwiftUI** - Clean, native macOS interface\n- ✅ **Comprehensive Tests** - 100% coverage of structured output scenarios\n\n## Requirements\n\n- macOS 15.4+ (Sequoia)\n- Xcode 16.0+\n- Apple Intelligence enabled\n- Python 3.8+ (for testing)\n\n## Installation\n\n### 1. Clone the repository\n\n```bash\ngit clone https://github.com/YOUR_USERNAME/giant_big.git\ncd giant_big\n```\n\n### 2. Open in Xcode\n\n```bash\nopen giant_big.xcodeproj\n```\n\n### 3. Build and Run\n\nPress `Cmd+R` or click the Run button in Xcode.\n\nThe server will start on `http://localhost:8888`.\n\n## API Usage\n\n### Basic Chat Completion\n\n```bash\ncurl -X POST http://localhost:8888/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"apple-intelligence\",\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"Hello!\"}\n    ]\n  }'\n```\n\n### Streaming Response\n\n```bash\ncurl -N -X POST http://localhost:8888/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"apple-intelligence\",\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"Count from 1 to 5\"}\n    ],\n    \"stream\": true\n  }'\n```\n\n### Structured Output\n\n```bash\ncurl -X POST http://localhost:8888/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"apple-intelligence\",\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"Generate a person named Alice, age 28\"}\n    ],\n    \"response_format\": {\n      \"type\": \"json_schema\",\n      \"json_schema\": {\n        \"name\": \"Person\",\n        \"strict\": true,\n        \"schema\": {\n          \"type\": \"object\",\n          \"properties\": {\n            \"name\": {\"type\": \"string\"},\n            \"age\": {\"type\": \"integer\"}\n          },\n          \"required\": [\"name\", \"age\"],\n          \"additionalProperties\": false\n        }\n      }\n    }\n  }'\n```\n\n### Multi-turn Conversation\n\n```bash\ncurl -X POST http://localhost:8888/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"apple-intelligence\",\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"My name is Bob\"},\n      {\"role\": \"assistant\", \"content\": \"Nice to meet you, Bob!\"},\n      {\"role\": \"user\", \"content\": \"What is my name?\"}\n    ]\n  }'\n```\n\n## Testing\n\n### Install Python Dependencies\n\n```bash\ncd tests\npip3 install -r requirements.txt\n```\n\n### Run Tests\n\n```bash\npython3 test_structured_output.py\n```\n\n### Test Coverage\n\nThe test suite covers all JSON Schema features:\n\n- ✅ Basic types (string, integer, number, boolean)\n- ✅ Array types (string[], number[], boolean[], object[])\n- ✅ Nested objects (single-level, multi-level)\n- ✅ Enum types (anyOf constraints)\n- ✅ Constraints (minimum, maximum, minItems, maxItems)\n- ✅ Optional fields (isOptional: true)\n- ✅ Complex nested structures (arrays of objects)\n- ✅ Edge cases (boundary values, empty optionals)\n\n## Architecture\n\n### Project Structure\n\n```\ngiant_big/\n├── giant_big/\n│   ├── APIServer.swift          # Core HTTP server and API logic\n│   ├── SchemaConverter.swift    # JSON Schema to DynamicGenerationSchema converter\n│   ├── ServerStatusView.swift   # SwiftUI status interface\n│   └── giant_bigApp.swift       # Application entry point\n├── tests/\n│   ├── schemas/                 # JSON Schema test files\n│   │   ├── test_cases.json      # Test configuration\n│   │   ├── basic_types.json\n│   │   ├── array_types.json\n│   │   ├── nested_objects.json\n│   │   ├── enum_types.json\n│   │   ├── constraints.json\n│   │   ├── optional_fields.json\n│   │   ├── complex_nested.json\n│   │   └── edge_cases.json\n│   ├── test_structured_output.py\n│   ├── validators.py\n│   └── requirements.txt\n└── README.md\n```\n\n### Key Components\n\n#### APIServer.swift (734 lines)\n- HTTP request parsing and routing\n- OpenAI API compatibility layer\n- Streaming response handling (SSE)\n- Multi-turn conversation management\n- Error handling and validation\n\n#### SchemaConverter.swift (258 lines)\n- Converts OpenAI JSON Schema to Apple's `DynamicGenerationSchema`\n- Supports all JSON Schema types and constraints\n- Recursive handling of nested structures\n- Dependency management for schema references\n\n#### ServerStatusView.swift (183 lines)\n- Real-time server status display\n- Request statistics and monitoring\n- Modern SwiftUI interface with `.ultraThinMaterial`\n\n## Supported JSON Schema Features\n\n### Types\n- `string` - Text values\n- `integer` - Whole numbers\n- `number` - Decimal numbers (Double)\n- `boolean` - true/false values\n- `array` - Lists of values\n- `object` - Nested structures\n- `enum` - Enumerated string values (anyOf)\n\n### Constraints\n- `minimum` / `maximum` - Numeric bounds\n- `minItems` / `maxItems` - Array length bounds\n- `required` - Required fields\n- `additionalProperties` - Strict mode (false)\n\n### Advanced Features\n- Nested objects (multi-level)\n- Arrays of objects\n- Optional fields\n- Enum constraints (anyOf)\n- Schema references\n\n## API Endpoints\n\n### POST /v1/chat/completions\n\nOpenAI-compatible chat completion endpoint.\n\n**Request Body:**\n```json\n{\n  \"model\": \"apple-intelligence\",\n  \"messages\": [\n    {\"role\": \"user\", \"content\": \"Hello\"}\n  ],\n  \"stream\": false,\n  \"response_format\": {\n    \"type\": \"json_schema\",\n    \"json_schema\": { ... }\n  }\n}\n```\n\n**Response:**\n```json\n{\n  \"object\": \"chat.completion\",\n  \"model\": \"apple-intelligence\",\n  \"choices\": [{\n    \"finish_reason\": \"stop\",\n    \"message\": {\n      \"content\": \"Hello! How can I help you?\",\n      \"role\": \"assistant\"\n    },\n    \"index\": 0\n  }],\n  \"created\": 1234567890,\n  \"id\": \"chatcmpl-xxxxx\",\n  \"usage\": {\n    \"prompt_tokens\": 0,\n    \"completion_tokens\": 0,\n    \"total_tokens\": 0\n  }\n}\n```\n\n### GET /v1/models\n\nList available models.\n\n**Response:**\n```json\n{\n  \"object\": \"list\",\n  \"data\": [{\n    \"id\": \"apple-intelligence\",\n    \"object\": \"model\",\n    \"created\": 1234567890,\n    \"owned_by\": \"apple\"\n  }]\n}\n```\n\n## Technical Details\n\n### Concurrency\n- Built with Swift 6 strict concurrency\n- Uses `async/await` for all asynchronous operations\n- `@MainActor` isolation for UI updates\n- `nonisolated` for network operations\n- `Sendable` protocol for thread-safe data\n\n### Networking\n- Apple's Network framework (`NWListener`, `NWConnection`)\n- HTTP/1.1 protocol\n- Server-Sent Events (SSE) for streaming\n- Port 8888 (configurable)\n\n### Apple Intelligence Integration\n- `LanguageModelSession` for stateful conversations\n- `Transcript` for multi-turn dialogue\n- `DynamicGenerationSchema` for runtime structured output\n- `GenerationSchema` for validated schemas\n- `GeneratedContent` for structured responses\n\n## License\n\nMIT License - See LICENSE file for details\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Acknowledgments\n\n- Built with Apple's Foundation Models framework\n- Inspired by OpenAI's API design\n- Uses Swift 6 modern concurrency features\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbingowon%2Fgiant_big","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbingowon%2Fgiant_big","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbingowon%2Fgiant_big/lists"}