Orchard Core AI Chat Copilot - Prompt Templates
Configure the GitHub Copilot Chat Orchestrator
You are an Orchard Core expert. Generate configuration, recipes, and extension code for the GitHub Copilot SDK-based chat orchestrator. This module is an alternative orchestration runtime, not an Orchard AI provider connection or deployment provider.
Guidelines
- Enable
CrestApps.OrchardCore.AI.Chat.Copilotto select GitHub Copilot orchestration on profiles, profile-source templates, and Chat Interactions. CopilotOptionsConfigurationbindsCrestApps:AI:Copilotshell configuration and then overlays configuredCopilotSettings.- Tenant settings take precedence when
AuthenticationTypeis non-default orHasStoredConfiguration()is true. - Use
GitHubOAuthfor user or profile GitHub credentials andApiKeyfor a directly configured model provider. NotConfiguredintentionally disables the Copilot orchestrator for a tenant.- OAuth mode requires a GitHub app (the settings card walks through creating one), a Copilot-entitled identity, and the callback URL
/copilot/OAuthCallback. - OAuth settings protect the client secret; API-key settings protect the provider API key with ASP.NET Core Data Protection.
- API-key mode supports
openai,azure, andanthropicprovider types. - Azure API-key mode requires an Azure API version and API key. Keep the base URL at the Azure resource URL.
- Select a model, effort
Default,Low,Medium, orHigh, and whether to allow all tool executions per profile, template, or interaction. - In OAuth mode, interactions normally use encrypted user credentials. Profile edit flows can store credentials on the profile for shared profile-scoped access.
- Profile credentials are shared by everyone who uses that profile. Treat them as an administrator-controlled capability.
CopilotAuthControllervalidates local return URLs and uses__popup__only for the profile-editor popup flow.- Install CrestApps packages in the web/startup project.
Feature Overview
| Feature | Feature ID | Purpose |
|---|---|---|
| AI Services | CrestApps.OrchardCore.AI | Shared AI profile and orchestration infrastructure |
| AI Copilot Orchestrator | CrestApps.OrchardCore.AI.Chat.Copilot | Copilot SDK orchestration and tenant settings |
| AI Chat | CrestApps.OrchardCore.AI.Chat | Profile chat UI |
| AI Chat Interactions | CrestApps.OrchardCore.AI.Chat.Interactions | Ad-hoc interaction UI and SignalR hub |
Install and Enable
Install the package in the web/startup project:
dotnet add package CrestApps.OrchardCore.AI.Chat.Copilot
{
"steps": [
{
"name": "Feature",
"enable": [
"CrestApps.OrchardCore.AI",
"CrestApps.OrchardCore.AI.Chat.Copilot",
"CrestApps.OrchardCore.AI.Chat"
],
"disable": []
}
]
}
Shell Configuration
Provide non-secret defaults through the section used by CopilotOptionsConfiguration:
{
"CrestApps": {
"AI": {
"Copilot": {
"AuthenticationType": "ApiKey",
"ProviderType": "openai",
"BaseUrl": "https://api.openai.com/v1",
"DefaultModel": "gpt-4o",
"WireApi": "completions"
}
}
}
}
Use environment variables or a secret store for ApiKey and OAuth client secrets. Tenant settings win for every value they hold. Keys: AuthenticationType (NotConfigured, GitHubOAuth, ApiKey), ClientId, ClientSecret and Scopes for OAuth; ProviderType, BaseUrl, ApiKey, DefaultModel, WireApi and AzureApiVersion for API-key mode. The example is a tenant App_Data/Sites/{tenant}/appsettings.json; the host file wraps the same keys in OrchardCore, for example OrchardCore__CrestApps__AI__Copilot__ApiKey.
CrestApps.Core reads CopilotOptions through IOptionsMonitor<CopilotOptions>. The module registers services.AddSignalOptionsChangeTokenSource<CopilotOptions>() and the settings editor calls IOptionsUpdateNotifier.RequestUpdate<CopilotOptions>() on save, so saved settings apply without a tenant restart. Code of your own that reads Copilot settings must also use IOptionsMonitor<CopilotOptions>; see orchardcore-site-settings.
Configure GitHub OAuth
Use OAuth when sessions should use models entitled to a GitHub identity:
- In GitHub, open Settings → Developer settings → GitHub Apps → New GitHub App, with an app name and the site's homepage URL. The Copilot card shows these steps with the exact callback URL to copy.
- Set the Callback URL to
https://your-domain.example/copilot/OAuthCallback, uncheck Webhook → Active (webhooks are not needed), and grant Copilot Chat → Read-only under Account permissions so models can be listed. - Create the app, copy the Client ID, generate a client secret, and enter both in Settings → Artificial Intelligence → Copilot (the secret is stored encrypted).
- Select GitHub Signed-in User authentication.
- Ask the user to select Sign in with GitHub.
- Select an available Copilot model after authorization.
The OAuth flow requests user:email and read:org. CopilotAuthController.AuthorizeGitHub generates the authorization redirect and OAuthCallback exchanges the code, stores the encrypted credential, and returns to a safe local URL or closes the popup.
Configure API-Key Authentication
Use API-key mode when the Copilot orchestration API should call a configured provider without a Copilot subscription:
- Go to Settings → Artificial Intelligence → Copilot.
- Select API Key authentication.
- Select
openai,azure, oranthropic. - Set the base URL, encrypted API key, default model, and wire API format.
- For Azure, set the Azure API version.
- Save the settings.
Use completions for the compatible chat-completions wire format. Use responses only with a provider and model that support the Responses API.
Select Copilot on a Profile
- Edit an AI Profile.
- Select GitHub Copilot Orchestrator.
- In OAuth mode, complete GitHub sign-in if necessary.
- Select a model and effort level.
- Decide whether Allow all tool executions is appropriate.
- Save the profile.
Copilot does not use the ordinary connection and deployment fields. AIProfileCopilotDisplayDriver instead stores CopilotSessionMetadata. The orchestrator resolves profile credentials before user credentials. Model pickers show each model's Copilot cost multiplier, for example (x1) or (x3), when GitHub reports one. Allow all tool executions is checked by default.
The orchestrator is registered under the name copilot. A recipe sets it with OrchestratorName and the per-profile values in CopilotSessionMetadata:
{
"steps": [
{
"name": "AIProfile",
"Profiles": [
{
"Name": "copilot-assistant",
"DisplayText": "Copilot Assistant",
"Type": "Chat",
"OrchestratorName": "copilot",
"Properties": {
"CopilotSessionMetadata": {
"CopilotModel": "gpt-4o",
"ReasoningEffort": "Default",
"IsAllowAll": false
}
}
}
]
}
]
}
Never put OAuth tokens in a recipe; profile-scoped credentials are created by signing in from the profile editor.
Reuse Settings with a Profile Template
For a profile-source template, configure the Copilot model, effort, and allow-all setting once. AIProfileTemplateCopilotDisplayDriver copies those values when the template creates a profile.
Avoid profile-scoped OAuth credentials unless the profile is intentionally a shared service identity. A user-level credential is safer for individual users.
Configure a Chat Interaction
Enable the interactions feature when creating ad-hoc sessions:
{
"steps": [
{
"name": "Feature",
"enable": [
"CrestApps.OrchardCore.AI",
"CrestApps.OrchardCore.AI.Chat.Copilot",
"CrestApps.OrchardCore.AI.Chat.Interactions"
],
"disable": []
}
]
}
ChatInteractionCopilotDisplayDriver and CopilotChatInteractionSettingsHandler save Copilot model, reasoning effort, and allow-all settings as CopilotSessionMetadata.
Authentication Callback Endpoints
| Route | Handler | Purpose |
|---|---|---|
| /copilot/Authorize | AuthorizeGitHub | Starts OAuth and validates the local return URL |
| /copilot/OAuthCallback | OAuthCallback | Exchanges the authorization code and stores credentials |
| /copilot/api/status | CopilotAuthEndpoints GET handler | Returns current-user status and tenant configuration state |
| /copilot/api/models | CopilotAuthEndpoints GET handler | Lists available models for the signed-in user |
| /copilot/api/disconnect | CopilotAuthEndpoints POST handler | Removes current-user OAuth credentials after antiforgery validation |
Permission Management
CopilotPermissionProvider supplies ManageCopilotSettings, granted to Administrators by default. Restrict it to trusted operators because it controls OAuth application credentials and provider API keys.
Security Checklist
- Never commit OAuth client secrets, OAuth tokens, or API keys.
- Use protected tenant settings only through the settings editor or a secure deployment process.
- Validate every OAuth callback URL exactly, including the
/copilot/OAuthCallbackpath. - Prefer user-scoped OAuth credentials over profile-scoped credentials.
- Enable allow-all tool execution only for profiles whose selected tools and users are trusted.
- Use normal AI Profile and AI Tool permissions in addition to Copilot settings permissions.