Skip to content

Commit e2b27b0

Browse files
CopilotMikeAlhayek
andcommitted
Add comprehensive documentation for AI Profile Templates
- Add AI Profile Templates section to README - Include examples of creating custom templates - Document template registration and UI usage - Explain benefits and best practices Co-authored-by: MikeAlhayek <24724371+MikeAlhayek@users.noreply.github.com>
1 parent 04527ea commit e2b27b0

1 file changed

Lines changed: 110 additions & 0 deletions

File tree

  • src/Modules/CrestApps.OrchardCore.AI

src/Modules/CrestApps.OrchardCore.AI/README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [AI Connection Management](#ai-connection-management)
1111
- [AI Data Source Management](#ai-data-source-management)
1212
- [Defining Chat Profiles Using Code](#defining-chat-profiles-using-code)
13+
- [AI Profile Templates](#ai-profile-templates)
1314
- [AI Tool Management Feature](#ai-tool-management-feature)
1415
- [Extending AI Chat with Custom Functions](#extending-ai-chat-with-custom-functions)
1516
- [Using AI Tool Sources](#using-ai-tool-sources)
@@ -277,6 +278,115 @@ public sealed class SystemDefinedAIProfileMigrations : DataMigration
277278
278279
---
279280

281+
### AI Profile Templates
282+
283+
**AI Profile Templates** provide a way to create reusable, pre-configured AI profile settings that users can select when creating new profiles. Templates streamline the profile creation process by pre-filling essential settings such as system messages, parameters, and model configurations.
284+
285+
#### Benefits of AI Profile Templates
286+
287+
- **Rapid profile creation** - Pre-fill settings instead of configuring each parameter manually
288+
- **Standardization** - Offer consistent, tested configurations for common use cases
289+
- **Improved user experience** - Guide users with pre-configured templates
290+
- **Flexibility** - Users can customize template settings after selection
291+
292+
#### Creating Custom AI Profile Templates
293+
294+
To create a custom template, implement the `IAIProfileTemplate` interface:
295+
296+
```csharp
297+
using CrestApps.OrchardCore.AI;
298+
using CrestApps.OrchardCore.AI.Core.Models;
299+
using CrestApps.OrchardCore.AI.Models;
300+
using Microsoft.Extensions.Localization;
301+
using OrchardCore.Entities;
302+
303+
namespace MyModule.Templates;
304+
305+
public sealed class MyCustomTemplate : IAIProfileTemplate
306+
{
307+
private readonly IStringLocalizer<MyCustomTemplate> _localizer;
308+
309+
public MyCustomTemplate(IStringLocalizer<MyCustomTemplate> localizer)
310+
{
311+
_localizer = localizer;
312+
}
313+
314+
// Unique identifier for the template
315+
public string Name => "MyCustomTemplate";
316+
317+
// Display name shown in the UI
318+
public LocalizedString DisplayName => _localizer["My Custom Template"];
319+
320+
// Description shown in the UI
321+
public LocalizedString Description => _localizer["Optimized for specific use case."];
322+
323+
// Profile source compatibility (null = compatible with all sources)
324+
public string ProfileSource => "OpenAI"; // or null for universal compatibility
325+
326+
// Apply template configuration to the profile
327+
public Task ApplyAsync(AIProfile profile)
328+
{
329+
ArgumentNullException.ThrowIfNull(profile);
330+
331+
// Configure profile type
332+
profile.Type = AIProfileType.Chat;
333+
profile.TitleType = AISessionTitleType.Generated;
334+
profile.WelcomeMessage = "Hello! How can I help you?";
335+
336+
// Configure AI parameters
337+
var metadata = profile.As<AIProfileMetadata>();
338+
metadata.SystemMessage = "You are a helpful assistant.";
339+
metadata.Temperature = 0.7f;
340+
metadata.MaxTokens = 2000;
341+
metadata.TopP = 1.0f;
342+
metadata.FrequencyPenalty = 0.0f;
343+
metadata.PresencePenalty = 0.0f;
344+
metadata.PastMessagesCount = 10;
345+
346+
profile.Put(metadata);
347+
348+
return Task.CompletedTask;
349+
}
350+
}
351+
```
352+
353+
#### Registering AI Profile Templates
354+
355+
Register your template in the module's `Startup` class:
356+
357+
```csharp
358+
public sealed class Startup : StartupBase
359+
{
360+
public override void ConfigureServices(IServiceCollection services)
361+
{
362+
// Register the template
363+
services.AddAIProfileTemplate<MyCustomTemplate>();
364+
}
365+
}
366+
```
367+
368+
#### Using Templates in the UI
369+
370+
Once registered, templates appear in a dropdown when creating new AI profiles:
371+
372+
1. Navigate to **Artificial Intelligence****Profiles** in the admin menu
373+
2. Click **Add Profile** and select a provider
374+
3. Select a template from the **Template** dropdown (optional)
375+
4. The profile form will be pre-filled with the template's settings
376+
5. Customize any settings as needed
377+
6. Save the profile
378+
379+
#### Example Templates
380+
381+
The OpenAI module includes example templates:
382+
383+
- **AutoComplete** - Optimized for code completion with lower temperature and token limits
384+
- **General Chat Assistant** - Balanced settings for conversational AI
385+
386+
These templates demonstrate best practices for creating reusable profile configurations.
387+
388+
---
389+
280390
## AI Tool Management Feature
281391

282392
### Extending AI Chat with Custom Functions

0 commit comments

Comments
 (0)