Commit a32de60
authored
feat: InferPage visual & functional improvements (#122)
* chat main layout
* file attachment
* stop button + some cleaning
* Use BackendType for backend config/UI
Refactor backend selection to use BackendType everywhere and simplify API key handling. Added Extensions.GetApiKeyVariable to map backends to env vars; Program now sets Utils.BackendType from the CLI arg, prompts for missing API keys (and marks Utils.HasApiKey), and only registers MaIN services when a non-self backend is selected. Utils was simplified: removed per-backend booleans, added BackendType, HasApiKey, IsLocal helper and moved Reason flag. UI updates: NavBar shows backend and model badges (with color/display name logic including "Local Ollama"), and Home.razor now branches on BackendType and uses Utils.IsLocal for MessageType. Also trimmed launchSettings applicationUrl.
* Color fix
* fix: stream tokens progressively for file-based chat
* fix theme color change (disco problem)
* post merge fixes
* update show-reasoning button
* fix stop button
* Add themeManager and replace eval-based theme access
Introduce a small JS themeManager in App.razor that bootstraps theme on page load (reads localStorage, parses JSON, and sets documentElement data-theme for dark mode) and exposes save/load helpers. Replace prior eval-based localStorage/document access in NavBar.razor and Home.razor with calls to themeManager.load, and update component logic to derive UI mode/accent color from the returned value. This centralizes theme persistence, avoids using eval, and provides safer parsing and fallbacks.
* Use LLMApiRegistry for API keys in IferPage Program.cs
Remove the old BackendType extension and centralize API key metadata in LLMApiRegistry (moved to MaIN.Domain.Models.Concrete). Program.cs now looks up the registry entry for each BackendType to read ApiKeyEnvName instead of calling GetApiKeyVariable. Updated numerous LLM and image service files (and McpService) to reference the new namespace. This change consolidates API key configuration and removes the duplicated extension method.
* fix MemoryStream leaks + multi-attachments issue
* smarter scroll
* Handle unregistered ai models; Support images input in cloud LLM
Add multi-image support and extract image bytes from uploaded files for LLM services; improve model ID/instance handling and model selection flow.
- Message: replace single byte[] Image with List<byte[]> Images and keep a backward-compatible Image getter/setter.
- Chat: preserve raw ModelId string, safely try to resolve model instance (no throws), and sync ModelInstance with internal id field.
- Home.razor: unify model resolution into a local variable and choose GenericLocalModel/GenericCloudModel when registry lookup fails.
- AnthropicService & OpenAiCompatibleService: add ExtractImageFromFiles to load image file bytes into Message.Images, remove consumed file entries, update HasImages/BuildMessageContent to iterate images, and extend image type detection (HEIC/HEIF, AVIF and more extensions).
These changes enable passing uploaded images to compatible LLM backends while maintaining backward compatibility and preventing exceptions when models are missing.
* paste and drag&drop files/images
* Add image attachment support and previews
Add client-side support for image attachments: show inline thumbnails for selected images, history image previews, paste handling, dismiss buttons, and update input/send logic to include images alongside files. Introduce _selectedImages and ImageExtensions, update MessageExt to store AttachedImages, and ensure proper disposal of image streams. Add CSS for image-preview and history-image-preview styling. On the service side, route messages that include images through a SearchAsync + context-enhanced chat flow (streaming and non-streaming) and adjust token handling/return values accordingly.
* Add image-generation support and UI
Introduce image-generation capability across the app: add IImageGenerationModel and HasImageGeneration on AIModel; mark cloud models (DALL·E3, new gpt-image-1 and grok-2-image) as image generators. Update UI to render generated images with download and copy-to-clipboard actions (Home.razor changes, CopyImageToClipboard interop + editor.js). Improve visual/model detection in Utils to use ModelRegistry with a fallback set of known image-generation IDs. Increase SignalR hub max message size to 10MB (Program.cs) to allow larger image transfers and add CSS for generated image layout and controls.
* Replace Visual flag with ImageGen and add vision support
Rename the old "Visual" concept to a clearer "ImageGen" across the codebase and add vision detection/flags. Key changes:
- Domain & storage: Chat.Visual -> Chat.ImageGen, ChatDocument.ImageGen, DTO and DB mappings updated (SQL/SQLite repos).
- API: removed EnableVisual(); added WithModel(AIModel model, bool? imageGen = null) to allow explicit imageGen override (defaults to model capability).
- Interfaces: removed EnableVisual from builder interfaces.
- Services/handlers: ChatService, AgentService, StartCommandHandler, AnswerCommandHandler and step handlers updated to use ImageGen logic when routing to image-gen or LLM services; TTS gating now checks ImageGen.
- Mappers: ChatMapper and DTO mappings updated to use ImageGen.
- UI: InferPage and NavBar updated to show Image Gen and Vision badges; Home.razor now computes message content/reasoning via MessageExt.ComputedContent/ComputedReasoning; MessageExt gains HasReasoning and computed fields.
- Utils: Reason is now computed from registered model capabilities and ImageGen is mutually exclusive with reasoning; added Vision detection and model lists.
- Examples & tests: updated to call WithModel(..., imageGen: true) or model-based API accordingly.
Why: clarifies semantics between image generation and visual/vision capabilities, centralizes model-driven behavior, and enables explicit overrides for image generation behavior.
* Handle base64 images in OpenAiImageGenService
Rename ImageGenDalleService to OpenAiImageGenService and update response handling to support OpenAI base64 (b64_json) image payloads. ProcessOpenAiResponse now returns byte[] and will decode b64_json or download from a URL; callers now receive image bytes directly. Add JsonPropertyName for b64_json, reorder/add necessary usings, and remove unused MaIN.Services.Services.LLMService.Utils imports from Gemini, OpenAi and Xai image services. These changes enable handling both base64 and URL image responses and standardize the OpenAI image service name.
* Add missing IVisionModel in cloud models
* versioning
* fix typo1 parent 0957664 commit a32de60
52 files changed
Lines changed: 1691 additions & 532 deletions
File tree
- Examples/Examples/Chat
- MaIN.Core.IntegrationTests
- Releases
- src
- MaIN.Core.UnitTests
- MaIN.Core
- Hub/Contexts
- Interfaces/ChatContext
- MaIN.Domain
- Entities
- Models
- Abstract
- Concrete
- MaIN.InferPage
- Components
- Layout
- Pages
- Properties
- wwwroot
- MaIN.Infrastructure
- Models
- Repositories
- Sqlite
- Sql
- MaIN.Services
- Dtos
- Mappers
- Services
- Abstract
- ImageGenServices
- LLMService
- Memory
- Steps/Commands
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | | - | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
100 | | - | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
| 86 | + | |
91 | 87 | | |
92 | 88 | | |
93 | 89 | | |
| |||
116 | 112 | | |
117 | 113 | | |
118 | 114 | | |
119 | | - | |
| 115 | + | |
120 | 116 | | |
121 | 117 | | |
122 | 118 | | |
| |||
205 | 201 | | |
206 | 202 | | |
207 | 203 | | |
208 | | - | |
| 204 | + | |
| 205 | + | |
209 | 206 | | |
210 | 207 | | |
211 | 208 | | |
| |||
231 | 228 | | |
232 | 229 | | |
233 | 230 | | |
234 | | - | |
| 231 | + | |
235 | 232 | | |
236 | 233 | | |
237 | 234 | | |
| |||
Lines changed: 4 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 21 | + | |
29 | 22 | | |
30 | 23 | | |
31 | 24 | | |
32 | 25 | | |
33 | 26 | | |
34 | 27 | | |
35 | | - | |
| 28 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
0 commit comments