OpenAssistant

Documentation · 3 documents

README and docs

Mirrored from the OpenAssistant repository every day. View on GitHub

README

OpenAssistant

OpenAssistant app icon

Archived SwiftUI client for the OpenAI Assistants API (v2) with strategy-driven local file preprocessing and memory-safe run polling.

Swift iOS License


Status: OpenAI shut down the Assistants API on August 26, 2026 (OpenAI deprecations), so this app can no longer reach it. The code stays here for reference; OpenResponses is its successor on the Responses API.

Overview

OpenAssistant is a native iOS client built using SwiftUI and the Combine framework that provides a mobile dashboard for interacting with the stateful OpenAI Assistants API (v2). The app enables users to manage custom AI assistants, thread histories, and vector store knowledge bases directly from an iPhone (or an iPad, in iPhone compatibility mode).

This repository now represents the legacy Assistants API line in Gunnar Hostetler’s product catalog. The active direct-API successor is OpenResponses, which moved the product focus to the Responses API.

Technical Problem Solved

Unlike simple chat completions that rely on stateless inputs, the OpenAI Assistants API is stateful and asynchronous. OpenAssistant orchestrates the multi-phase lifecycle of thread runs (Queued → In Progress → Completed) using a memory-safe, active timer-based polling system.

Additionally, because the Assistants API rejects common mobile formats (like HEIC images or RTF documents) directly, OpenAssistant implements an on-device preprocessing pipeline using the Strategy Pattern to convert these file formats locally before transmission. This saves bandwidth and prevents server-side failures.


Product Snapshot

DimensionDetail
PlatformiOS 16.0+, iPhone (runs on iPad in iPhone compatibility mode)
LanguageSwift
UISwiftUI
ArchitectureMVVM-S
Primary APIsOpenAI Assistants API (v2) / Firebase Analytics
StorageUserDefaults (via @AppStorage)
App StoreRemoved from sale on September 23, 2026
StatusArchived
LicenseMIT

Key Capabilities

  • Asynchronous Run Orchestration: Active polling pipeline (2.0s interval) with memory-safe [weak self] captures and explicit timer invalidation to prevent reference cycles.
  • Strategy-Driven File Preprocessing: Local, on-device conversion strategies (HEIC to JPEG and RTF to UTF-8 plain text) executing off the main thread. Audio files are not transcribed yet: the app uploads a placeholder note in their place (see Roadmap).
  • Decoupled State Synchronization: Cross-module notifications using NotificationCenter to synchronize lists (Assistants, Vector Stores) across tab views without direct ViewModel coupling.
  • Data Sovereignty: All API credentials reside in local user storage (UserDefaults) and connect directly to OpenAI over HTTPS, bypassing external proxy servers.
  • Adaptive UI & Design System: Responsive SwiftUI layouts utilizing dark/light/system appearance modes and custom feedback states (creating thread, running assistant, processing, completing).
  • Security Pre-Commit Hooks: Automated script verification preventing accidental commits of hardcoded developer API keys.
  • Successor Path: The repo remains useful as a reference for Assistants API-era mobile orchestration, but current product work now lives in OpenResponses.

How It Works

This flowchart maps the user experience from launching the app, through credential verification, and into main chat/vector store interaction pipelines:

flowchart TD
    Launch[Launch App] --> CheckKey{Has API Key?}
    CheckKey -->|No| Settings[Settings View]
    Settings -->|Enter Key| SaveKey[Save & Initialize]
    SaveKey --> Dashboard[Dashboard]
    CheckKey -->|Yes| Dashboard
    
    Dashboard --> VectorStore[Vector Stores]
    VectorStore --> FileIngest[File Ingest]
    FileIngest --> IngestStrategy[Apply Conversion Strategy]
    IngestStrategy --> Upload[Upload & Index]
    Upload --> Dashboard
    
    Dashboard --> Chat[Select Assistant & Chat]
    Chat --> SendMsg[Send Message]
    SendMsg --> LocalSave[Save locally]
    LocalSave --> ThreadRun[Run Thread]
    ThreadRun --> Poll{Run Done?}
    Poll -->|No| Poll
    Poll -->|Yes| FetchMsg[Fetch Output]
    FetchMsg --> SaveLocal[Deduplicate & Persist]
    SaveLocal --> Render[Render Output]

Architecture

OpenAssistant utilizes the MVVM-S design pattern. The View layer remains thin and declarative, observing reactive ViewModels that inherit from core base classes, which communicate with dedicated Services.

flowchart LR
    subgraph UI ["Views"]
        Chat[ChatView]
        Vector[VectorStoreListView]
        Settings[SettingsView]
    end
    subgraph Logic ["ViewModels"]
        VM_Chat[ChatViewModel]
        VM_Vector[VectorStoreManagerViewModel]
    end
    subgraph Storage ["Storage & Service"]
        S_API[OpenAIService]
        S_Upload[FileUploadService]
        P_Msg[MessageStore]
    end
    subgraph External ["Cloud"]
        E_OpenAI[OpenAI API]
    end
    
    UI --> Logic
    Logic --> Storage
    Storage --> External
    VM_Chat <--> P_Msg

Core Workflows

Strategy-Driven File Ingestion Pipeline

When a document is picked, the application routes the binary through an on-device conversion processor before packaging the payload:

flowchart TD
    A[Select File] --> B{Supported?}
    B -->|Yes| C[Read raw bytes]
    B -->|No| D{Extension?}
    D -->|heic| E[HEIC to JPEG]
    D -->|rtf| F[RTF to TXT]
    D -->|audio| G[Audio placeholder]
    D -->|unsupported| H[Throw Error]
    E --> C
    F --> C
    G --> C
    C --> I[POST /v1/files]
    I --> J[Link to Vector Store]

Data Flow

This diagram illustrates how data passes between the local device sandbox, secure transport layers, and external service boundaries:

flowchart TD
    subgraph Device ["On-Device Sandbox"]
        Key[API Key in AppStorage]
        Msg[Saved Messages in AppStorage]
        Tmp[Picked file read in place and uploaded from memory]
    end
    subgraph Transport ["Network Transport"]
        TLS[TLS Encryption]
    end
    subgraph Cloud ["External Services"]
        OpenAI[OpenAI Servers]
        Firebase[Firebase Telemetry]
    end

    Key --> TLS
    Tmp --> TLS
    TLS --> OpenAI
    Msg -.-> Msg
    Device --> Firebase

File Entry Points

ConcernFilesResponsibility
App EntryOpenAssistantApp.swiftBootstrapping, Firebase configuration, and environment object injection.
Main UI ShellMainTabView.swift / ContentView.swiftPrimary tab routing and settings layout.
API ClientOpenAIService.swiftBase networking client, headers, and request execution with backoff retry logic.
API ExtensionsOpenAIService-Assistant.swift, OpenAIService-Threads.swift, OpenAIService-Vector.swiftDomain-specific network mappings.
IngestionFileUploadService.swiftFile conversion, multipart parsing, and vector store upload coordination.
StorageMessageStore.swiftChat history JSON serialization, deduplication, and persistence.

Configuration

The app’s environment is parameterized by the following values:

SettingStorageDefaultRequiredPurpose
OpenAI_API_KeyUserDefaults (via @AppStorage)""YesToken for OpenAI API authorization.
appearanceModeUserDefaults (via @AppStorage)"System"YesDictates dark/light/system styling rules.
savedMessagesUserDefaults (via @AppStorage)nilNoSerialized chat history lists.
enableNewFeatureCompile-time flag (FeatureFlags.swift)falseYesControls the visibility of experimental features.

Build & Run

Local Setup Instructions

  1. Clone the Repository:
    git clone https://github.com/Gunnarguy/OpenAssistant.git
    cd OpenAssistant
  2. Execute the Setup Helper Script: The script checks prerequisites, runs CocoaPods installation, and installs local Git pre-commit security hooks to safeguard against API key leaks:
    chmod +x setup.sh
    ./setup.sh
  3. Select Signing Identity:
    • Open OpenAssistant.xcworkspace in Xcode 15+.
    • Navigate to the OpenAssistant target.
    • Under Signing & Capabilities, select your developer team and modify the Bundle Identifier.
  4. Build and Run:
    • Select an iOS 16.0+ Simulator or physical device.
    • Press ⌘+R to build and execute the application.

Testing

The repository does not currently contain automated unit test targets. All validation must be performed manually:

ValidationProcedureExpected Result
Build verificationRun xcodebuild -workspace OpenAssistant.xcworkspace -scheme OpenAssistant -sdk iphonesimulator build CODE_SIGNING_ALLOWED=NOBuild succeeds with zero errors.
Pre-Commit ScanAttempt to commit a file containing sk- followed by 32 or more letters or digitsCommit is aborted with a warning.
Manual QA (Onboarding)Clear API key in Settings, relaunch app.Settings sheet automatically opens.
Manual QA (Assistant)Create assistant “QA Bot”, select model, tap Save.Assistant appears in picker list.
Manual QA (Chat)Type “Hello” inside “QA Bot” thread, send message.Run lifecycle states progress to completed; text renders.

The Assistant and Chat rows need the Assistants API, which OpenAI shut down on August 26, 2026.


Privacy & Security

  • Local Storage Sandbox: API keys and message histories reside inside the app container’s sandbox. Picked files are read in place through security-scoped access and uploaded from memory.
  • Network Protection: App Transport Security defaults require TLS 1.2 or later, and all API traffic goes directly to OpenAI (api.openai.com). Requests are sent directly from the app to the API without a custom proxy server.
  • Pre-Commit Hook: Scans changed files locally for keys before staging commits to avoid remote exposure.
  • For detailed information, review SECURITY.md and PRIVACY.md.

Documentation

DocumentPurpose
ArchitectureSystem design, data flow, and service boundaries
SecuritySecret handling, local storage, and release checks
PrivacyData storage, API transmission, and user controls
RoadmapCurrent status, planned work, and known gaps
App Store NotesApp Store metadata, review notes, and release checklist
Case StudyEngineering retrospective and implementation notes

Roadmap

  • [x] Strategy-driven file format converters (JPEG, TXT conversions).
  • [x] Decoupled state notification bus.
  • [ ] Migrate credential storage from @AppStorage to secure Keychain Services.
  • [ ] Introduce automated unit tests and Mock APIs.
  • [ ] Implement true Speech-to-Text Whisper transcription in AudioTranscriptionStrategy.

License

OpenAssistant is licensed under the MIT License. See LICENSE for more details.