Files
ai_studio/README.md
T

120 lines
8.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AI Studio
Native SwiftUI chat for Apple silicon Macs running macOS 14 or later. Open `AIStudio.xcodeproj` and run the shared **AIStudio** scheme on **My Mac**. Xcode resolves the pinned Swift packages on the first build.
## 1. Set up a model
- **Ollama:** In **Settings → Models**, refresh the installed list and select a tag. The default server is `http://127.0.0.1:11434`. Use the same pane to pull, inspect, and delete models. Enter a remote HTTP or HTTPS base URL to use another server. The optional bearer token stays in memory and requires HTTPS for remote servers.
- **OpenAI-compatible:** In **Settings → Models**, choose the compatible backend, enter the API base URL (for example `http://127.0.0.1:1234/v1` for LM Studio), then refresh models and select the exact model ID. Remote URLs require HTTPS. An optional bearer token stays in memory and is cleared when the endpoint changes. The server manages model loading. Chat Completions streams the reply and any separately reported reasoning.
- **MLX:** In **Settings → MLX Library**, download and select a pinned SmolLM2 or Qwen3 model. **Settings → Models** also accepts a local model folder with configuration, tokenizer files, and safetensors weights. **Use Model** selects on-device inference. **Prefer Ollama** can fall back to the configured MLX folder when Ollama fails before emitting output.
- **Thinking:** The composer sends Boolean or named effort settings to Ollama. Supported MLX templates expose Default, Off, and On. Reported reasoning appears in an expandable section. If an Ollama request is interrupted after emitting text, reasoning, or a tool call, the router keeps that backend. **Stop** cancels generation and retains any partial output.
## 2. Chat with documents
Use **Documents** in the conversation toolbar to import PDF, UTF-8 text, Markdown, or CSV. Turn on document excerpts in the composer to include up to four matched passages with numbered source titles. Retrieval combines SQLite full-text ranking and on-device Apple sentence embeddings where available. Scanned PDFs require a text layer. When Ollama is selected, document opt-in sends the chosen excerpts to the configured server.
Chat history, older-message recall, and document indexes live in `~/Library/Application Support/AIStudio/studio.sqlite`. Documents are scoped to the selected conversation. Deleting a document removes its index and deleting a conversation removes its messages and documents. The app stores extracted excerpts and vectors locally. It leaves the original files in place.
## 3. Run a tool
Open **Toolbox**, enter an MCP HTTP endpoint, and choose **Discover Tools**. Select a tool, review the schema, enter its JSON arguments, and confirm the invocation. You can attach up to 8,000 characters of the result to the next message in the active conversation. The composer shows the attachment before it is sent.
For a local subprocess, select **Local stdio**, enter the full path of the
server executable, and add one argument per line. Choose **Start Server and
Discover…** and confirm. Use **Disconnect** to stop the subprocess. Local
stdio supports the MCP initialization handshake used by the 2024 and 2025
protocol revisions.
The HTTP client supports Streamable HTTP with current stateless discovery and legacy initialization, session headers, and JSON or server-sent event responses. Remote MCP endpoints require HTTPS. Optional bearer tokens stay in memory. Tool calls require explicit confirmation and are sent once. OAuth sign-in, modern stateless stdio, and server-requested follow-up interactions remain outside the supported MCP scope.
## 4. Customize prompts and review performance
Choose a **Global preset** in **Settings → Generation**. Default, Concise, Coding, Study,
Creative, and Custom are available across conversations. **Prompt Builder**
turns structured inputs into a prompt you can copy, put in the composer,
or save as the global system prompt. Global settings persist across launches.
Search conversation titles and messages in the sidebar. Rename the selected
chat with the pencil button. Completed replies render inline Markdown and fenced
code blocks with copy controls. The **Performance** dashboard keeps the last
50 generations across launches, including latency, duration, output size,
backend, and tokens per second when the provider supplies it.
## 5. Generation and local tools
**Settings → Generation** applies system instructions to future requests
without adding a transcript message. Save parameter overrides with **Apply
Parameters**. Blank fields inherit backend defaults, including AI Studio’s
1,024-token MLX cap. Shared settings include sampling temperature, top-p,
output token limit, repetition controls, and stop sequences. Ollama also accepts
context length, top-k, min-p, seed, frequency and presence penalties, keep-alive,
and JSON response mode. The compatible backend sends temperature, top-p, max tokens, stops, frequency and presence penalties, and JSON mode. Native MLX exposes rolling KV-cache size and prefill
step size. On failover, MLX uses the supported shared and MLX settings.
**Settings → Local Tools** runs a confirmed command through the installed
Docker CLI. It captures up to 128 KiB of combined output; you can copy that
output or explicitly attach it to the active chat. The Finder section can open
or reveal a selected file or folder, copy its path, or preview up to 8,000
bytes of a selected UTF-8 file. A preview can be explicitly attached to the
active chat. Docker commands and Finder actions are initiated from Settings.
**Settings → Runtime** shows the cached MLX model and available physical
memory. Set the idle unload interval, unload the cached model on demand,
or set an optional maximum weight-file size for new model loads. The model
weight limit measures safetensors on disk. It does not estimate total runtime
memory.
## Workspace and desktop preferences
Open **Workspace** to create reusable document stacks, store instructions as
Skills, save reference Contexts, save Prompts, or capture public UTF-8 pages as
Web Clips. Select the resources you want to include in the current chat. Knowledge stacks
show the number of locally embedded passages. If a connected MCP server
provides `search_knowledge`, enable **Search connected knowledge index for
this chat** to include results from that server, such as Local Knowledge’s
Chroma index.
Toolbox shows the connected MCP server beside the composer. Read
[Programming custom MCP servers](Docs/MCP.md) for configuration, the installed
Knowledge server, and troubleshooting.
Return sends and Shift–Return inserts a newline. **Settings → Appearance**
controls workspace mode, theme, accent, typography, spell checking and
automatic correction. **Settings → Workspace Data** exports the SQLite
workspace and restores an AI Studio backup after confirmation. Backup
reminders appear in that panel. **Settings → MLX Library** downloads catalog
models, registers existing local MLX folders, and scans a selected library
folder for compatible checkpoints. Settings → Models lists Ollama models
as rows with direct selection controls.
## Search and retrieve web sources
Choose **Toolbox → Web**. For in-app search, enter the URL of a SearXNG
`/search` endpoint with JSON enabled, then run your query. You can also
open a browser search and paste the chosen URL into **Retrieve Page**.
Retrieval extracts text from UTF-8 HTML and plain-text pages without
running page scripts. It keeps the final source URL. Attach an individual
result or a retrieved page to your next message after reviewing it.
Choose **Activate Web Toolset** in the **MCP Servers** tab to access the same
operations through the Toolbox tool list. With Built-In Web active, chat retrieves
up to two explicitly typed HTTP(S) URLs and adds their source text to the
request. Use `/search your query` or `Search the web for your query` to search
from chat using the configured SearXNG endpoint.
## Build and test
From the project root, run `Scripts/build.sh` to build and open AI Studio. It defaults to Debug. Use `./build.sh Release` for a Release build, or add `--no-launch` after the configuration to build without opening the app. Run `Scripts/test.sh` for XCTest, including the local MCP and Ollama management fixture. It requires Python 3 for the fixture and keeps its logs and results in the temporary build directory.
For opt-in live provider checks, use installed models or select a catalog download:
```sh
TEST_RUNNER_AISTUDIO_TEST_OLLAMA_URL=http://127.0.0.1:11434 \
TEST_RUNNER_AISTUDIO_TEST_OLLAMA_MODEL=your-installed-tag \
TEST_RUNNER_AISTUDIO_TEST_MLX_PATH=/path/to/local-model \
TEST_RUNNER_AISTUDIO_TEST_MODEL_DOWNLOAD=qwen3-0.6b-4bit \
./test.sh
```
See `Docs/RELEASE.md` for packaging, signing, and notarization.
See [phase progress](Docs/PHASES.md) for verification status and remaining work.