5 |
6 |
7 | Loading...
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Services/IRagService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Services;
5 |
6 | public interface IRagService
7 | {
8 | bool IsRagEnabled();
9 | string GetDocument(string? ragDocument, string? ragUserInput);
10 | }
11 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/semantic-kernel/model/Ask.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export interface IAsk {
5 | input: string;
6 | variables?: IAskVariables[];
7 | }
8 |
9 | export interface IAskVariables {
10 | key: string;
11 | value: string;
12 | }
13 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/components/views/index.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export * from './BackendProbe';
5 | export * from './ChatView';
6 | export * from './Error';
7 | export * from './Loading';
8 | export * from './Login';
9 | export * from './MissingEnvVariablesError';
10 |
11 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/semantic-kernel/model/CustomPlugin.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export interface ICustomPlugin {
5 | nameForHuman: string;
6 | nameForModel: string;
7 | authHeaderTag: string;
8 | authType: string;
9 | manifestDomain: string;
10 | }
11 |
--------------------------------------------------------------------------------
/src/chat-score/webapi/worker/common/base.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 |
4 | from abc import abstractmethod
5 | class BaseTask:
6 | @abstractmethod
7 | def worker_ready(self, concurrency: int):
8 | pass
9 |
10 | @abstractmethod
11 | def worker_stop(self):
12 | pass
--------------------------------------------------------------------------------
/src/picture-submission/webapi/server/service/ctfd/ticket.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 |
4 | from dataclasses import dataclass
5 | from dataclasses_json import DataClassJsonMixin
6 |
7 | @dataclass
8 | class CtfdAuthTicket(DataClassJsonMixin):
9 | id: int
10 | nonce: str
11 | cookie: str
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Storage/CtfdAuthApi.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Models.Storage;
5 |
6 | public class CtfdAuthApi
7 | {
8 | public string Nonce { get; set; } = string.Empty;
9 | public string Cookie { get; set; } = string.Empty;
10 | }
11 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Request/ExecutePlanParameters.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using CopilotChat.WebApi.Models.Response;
5 |
6 | namespace CopilotChat.WebApi.Models.Request;
7 |
8 | public class ExecutePlanParameters : Ask
9 | {
10 | public ProposedPlan? Plan { get; set; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/chat-score/webapp/src/libs/models/StatusUpdate.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export interface ConversationStatus {
5 | id: number;
6 | challenge_id: number;
7 | in_review: boolean;
8 | }
9 |
10 | export interface StatusUpdate {
11 | session_count: number;
12 | conversation_queue: ConversationStatus[];
13 | }
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Request/SemanticMemoryType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Models.Request;
5 |
6 | ///
7 | /// Types of semantic memories supported by chat-copilot.
8 | ///
9 | public enum SemanticMemoryType
10 | {
11 | LongTermMemory,
12 | WorkingMemory
13 | }
14 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Options/PrometheusTelemetryOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Options;
5 |
6 | public class PrometheusTelemetryOptions
7 | {
8 | public const string PropertyName = "PrometheusTelemetry";
9 |
10 | public string Endpoint { get; set; } = "http://localhost:4001";
11 | }
12 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/models/ChatMemorySource.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export interface ChatMemorySource {
5 | id: string;
6 | chatId: string;
7 | sourceType: string;
8 | name: string;
9 | hyperlink?: string;
10 | sharedBy: string;
11 | createdOn: number;
12 | size: number;
13 | }
14 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Request/DocumentScopes.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Models.Request;
5 |
6 | ///
7 | /// Scope of the document. This determines the collection name in the document memory.
8 | ///
9 | public enum DocumentScopes
10 | {
11 | Global,
12 | Chat,
13 | }
14 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Services/ISessionMetricService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Services;
5 |
6 | public interface ISessionMetricService
7 | {
8 | public void OnConnected(string connectionId);
9 | public void OnDisconnect(string connectionId);
10 |
11 | public void TrackUserId(string userId);
12 | }
13 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Auth/AuthPolicyName.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Auth;
5 |
6 | ///
7 | /// Holds the policy names for custom authorization policies.
8 | ///
9 | public static class AuthPolicyName
10 | {
11 | public const string RequireChatParticipant = "RequireChatParticipant";
12 | }
13 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/models/ChatUser.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export interface IChatUser {
5 | id: string;
6 | online: boolean;
7 | fullName: string;
8 | emailAddress: string;
9 | photo?: string; // TODO: [Issue #45] change this to required when we enable token / Graph support
10 | isTyping: boolean;
11 | }
12 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/semantic-kernel/model/AskResult.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { IChatMessage } from '../../models/ChatMessage';
5 |
6 | export interface IAskResult {
7 | message: IChatMessage;
8 | variables: ContextVariable[];
9 | }
10 |
11 | export interface ContextVariable {
12 | key: string;
13 | value: string;
14 | }
15 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Auth/ChatParticipantRequirement.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using Microsoft.AspNetCore.Authorization;
5 |
6 | namespace CopilotChat.WebApi.Auth;
7 |
8 | ///
9 | /// Used to require the chat to be owned by the authenticated user.
10 | ///
11 | public class ChatParticipantRequirement : IAuthorizationRequirement
12 | {
13 | }
14 |
--------------------------------------------------------------------------------
/src/chat-score/webapp/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/src/challenge-home/webapp/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/src/picture-submission/webapp/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Request/RagInput.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Text.Json.Serialization;
5 |
6 | namespace CopilotChat.WebApi.Models.Request;
7 |
8 | public class RagInput
9 | {
10 | [JsonPropertyName("document")]
11 | public string? Document { get; set; }
12 |
13 | [JsonPropertyName("userInput")]
14 | public string? UserInput { get; set; }
15 | }
16 |
--------------------------------------------------------------------------------
/src/chat-score/webapp/src/libs/models/Settings.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export interface ISettings {
5 | enableSound: boolean;
6 | darkMode: boolean;
7 | standardReplies: string[];
8 | }
9 |
10 | export const defaultSettings: ISettings = {
11 | enableSound: true,
12 | darkMode: false,
13 | standardReplies: [],
14 | };
15 |
16 | export const SETTINGS_KEY_NAME = "chat-score-settings";
--------------------------------------------------------------------------------
/src/chat-score/webapp/src/redux/app/hooks.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { useDispatch, useSelector } from 'react-redux'
5 | import type { AppDispatch, RootState } from './store'
6 |
7 | // Use throughout your app instead of plain `useDispatch` and `useSelector`
8 | export const useAppDispatch = useDispatch.withTypes()
9 | export const useAppSelector = useSelector.withTypes()
--------------------------------------------------------------------------------
/src/picture-submission/webapp/src/redux/app/hooks.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { useDispatch, useSelector } from 'react-redux'
5 | import type { AppDispatch, RootState } from './store'
6 |
7 | // Use throughout your app instead of plain `useDispatch` and `useSelector`
8 | export const useAppDispatch = useDispatch.withTypes()
9 | export const useAppSelector = useSelector.withTypes()
--------------------------------------------------------------------------------
/docker/ctfd/challenges_append.js:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | //Patch to perfom a reload of the page when a challenge is solved
5 | document.addEventListener('DOMContentLoaded', () => {
6 | setInterval(() => {
7 | const reloadCmd = localStorage.getItem('reloadCmd');
8 | if (reloadCmd) {
9 | localStorage.removeItem('reloadCmd');
10 | window.location.reload();
11 | }
12 | }, 1500);
13 | });
14 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Response/CtfdResponse.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Text.Json.Serialization;
5 |
6 | namespace CopilotChat.WebApi.Models.Response;
7 |
8 | public class CtfdResponse where T : class
9 | {
10 | [JsonPropertyName("success")]
11 | public bool Success { get; set; }
12 |
13 | [JsonPropertyName("data")]
14 | public T Data { get; set; } = default!;
15 | }
16 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/redux/features/users/UsersState.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export interface UsersState {
5 | users: Users;
6 | }
7 |
8 | export const initialState: UsersState = {
9 | users: {},
10 | };
11 |
12 | export type Users = Record;
13 |
14 | export interface UserData {
15 | id: string;
16 | displayName?: string;
17 | userPrincipalName?: string;
18 | }
19 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Auth/IAuthInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Auth;
5 |
6 | public interface IAuthInfo
7 | {
8 | ///
9 | /// The authenticated user's unique ID.
10 | ///
11 | public string UserId { get; }
12 |
13 | ///
14 | /// The authenticated user's name.
15 | ///
16 | public string Name { get; }
17 | }
18 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Request/ManualScoring.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Text.Json.Serialization;
5 |
6 | namespace CopilotChat.WebApi.Models.Request;
7 |
8 | public class ManualScoring
9 | {
10 | [JsonPropertyName("chatId")]
11 | public string ChatId { get; set; } = string.Empty;
12 |
13 | [JsonPropertyName("messageIndex")]
14 | public int MessageIndex { get; set; } = 0;
15 | }
16 |
--------------------------------------------------------------------------------
/docker/ctfd/docker-compose-dev.yml:
--------------------------------------------------------------------------------
1 | # Docker compose to spin up a dev environment for ctfd
2 |
3 | version: "3"
4 | services:
5 | redis:
6 | image: redis:latest
7 | ports:
8 | - 6379:6379
9 | ctfd:
10 | image: ctfd:latest
11 | build:
12 | context: .
13 | dockerfile: Dockerfile
14 | env_file:
15 | - .env
16 | environment:
17 | - REDIS_URL=redis://redis:6379
18 | ports:
19 | - 8000:8000
20 | depends_on:
21 | - redis
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Response/ScoringResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Text.Json.Serialization;
5 |
6 | namespace CopilotChat.WebApi.Models.Response;
7 |
8 | public class ScoringResult
9 | {
10 | [JsonPropertyName("passed")]
11 | public bool Passed { get; set; } = false;
12 |
13 | [JsonPropertyName("custom_message")]
14 | public string CustomMessage { get; set; } = string.Empty;
15 | }
16 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Response/AskResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 |
7 | namespace CopilotChat.WebApi.Models.Response;
8 |
9 | public class AskResult
10 | {
11 | public string Value { get; set; } = string.Empty;
12 |
13 | public IEnumerable>? Variables { get; set; } = Enumerable.Empty>();
14 | }
15 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Response/SpeechTokenResponse.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Models.Response;
5 |
6 | ///
7 | /// Token Response is a simple wrapper around the token and region
8 | ///
9 | public class SpeechTokenResponse
10 | {
11 | public string? Token { get; set; }
12 | public string? Region { get; set; }
13 | public bool? IsSuccess { get; set; }
14 | }
15 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Request/CtfdFlagSubmission.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Text.Json.Serialization;
5 |
6 | namespace CopilotChat.WebApi.Models.Request;
7 |
8 | public class CtfdFlagSubmission
9 | {
10 | [JsonPropertyName("challenge_id")]
11 | public int ChallengeId { get; set; } = 0;
12 |
13 | [JsonPropertyName("submission")]
14 | public string Submission { get; set; } = string.Empty;
15 | }
16 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Services/Ctfd/ICtfdFlagSubmissionService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Threading.Tasks;
5 | using CopilotChat.WebApi.Models.Storage;
6 |
7 | namespace CopilotChat.WebApi.Services.Ctfd;
8 |
9 | public interface ICtfdFlagSubmissionService
10 | {
11 | CtfdAuthApi? GetCtfdAuth();
12 | Task SubmitFlagAsync(string chatId);
13 | Task SubmitFlagAsync(string chatId, CtfdAuthApi ctfdAuth);
14 | }
15 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Services/IPrometheusTelemetryService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Services;
5 |
6 | public interface IPrometheusTelemetryService
7 | {
8 | ///
9 | /// Records a metric with a given value.
10 | ///
11 | ///
12 | ///
13 | public void RecordMetric(string metricName, double value);
14 | }
15 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Storage/IStorageEntity.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 |
6 | namespace CopilotChat.WebApi.Storage;
7 |
8 | public interface IStorageEntity : ICloneable
9 | {
10 | ///
11 | /// Unique ID of the entity.
12 | ///
13 | string Id { get; set; }
14 |
15 | ///
16 | /// Partition key value.
17 | ///
18 | string Partition { get; }
19 | }
20 |
--------------------------------------------------------------------------------
/src/chat-score/webapi/worker/common/imports.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 |
4 | import redis
5 | import os
6 | from flask_socketio import SocketIO
7 | from celery.signals import worker_process_init, worker_ready, worker_shutting_down
8 |
9 | from server.environ import ENV_NAME_REDIS, REDIS_URL
10 |
11 |
12 | socket_io = SocketIO(message_queue=os.environ.get(ENV_NAME_REDIS, REDIS_URL))
13 | r = redis.Redis.from_url(os.environ.get(ENV_NAME_REDIS, REDIS_URL))
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Response/CtfdFlagSubmissionResponse.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Text.Json.Serialization;
5 |
6 | namespace CopilotChat.WebApi.Models.Response;
7 |
8 | public class CtfdFlagSubmissionResponse
9 | {
10 | [JsonPropertyName("status")]
11 | public string Status { get; set; } = string.Empty;
12 |
13 | [JsonPropertyName("message")]
14 | public string Message { get; set; } = string.Empty;
15 | }
16 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/models/ChatArchive.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { IChatMessage } from './ChatMessage';
5 |
6 | export interface ChatArchive {
7 | Schema: { Name: string; Version: number };
8 | Configurations: { EmbeddingAIService: string; EmbeddingDeploymentOrModelId: string };
9 | ChatTitle: string;
10 | ChatHistory: IChatMessage[];
11 | Embeddings: any[]; // TODO: [Issue #47] Add type. See Bot.cs
12 | }
13 |
--------------------------------------------------------------------------------
/docker/chat-score/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3"
2 | services:
3 | redis:
4 | image: redis
5 | ports:
6 | - 6379:6379
7 | chat-score:
8 | image: chat-score
9 | build:
10 | context: ../../
11 | dockerfile: docker/chat-score/Dockerfile
12 | args:
13 | - PAT=${PAT}
14 | ports:
15 | - 5000:5000
16 | depends_on:
17 | - redis
18 | environment:
19 | - REDIS_URL=redis://redis:6379/0
20 | - SCORING_KEY=secret
21 | - SECRET_KEY=secret
22 |
--------------------------------------------------------------------------------
/src/loadbalancer/config-example.yaml:
--------------------------------------------------------------------------------
1 | reverseProxy:
2 | host: ""
3 | port: 8080
4 | tokenCutoff: 500
5 | # authKey: "TODO PUT YOUR AUTH KEY HERE"
6 |
7 | endpoints:
8 | # TODO: Add your own endpoints here
9 | #
10 | # - url: "http://example.com"
11 | # key: "key"
12 | # type: "azure"
13 | # models:
14 | # - name: "gpt-4o"
15 | # capacityToken: 150000
16 | # capacityRequest: 900
17 | # - name: "text-embedding-ada-002"
18 | # capacityToken: 240000
19 | # capacityRequest: 1440
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/models/ServiceInfo.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export interface MemoryStore {
5 | types: string[];
6 | selectedType: string;
7 | }
8 |
9 | export interface HostedPlugin {
10 | name: string;
11 | manifestDomain: string;
12 | }
13 |
14 | export interface ServiceInfo {
15 | memoryStore: MemoryStore;
16 | availablePlugins: HostedPlugin[];
17 | version: string;
18 | isContentSafetyEnabled: boolean;
19 | }
20 |
--------------------------------------------------------------------------------
/src/challenge-home/webapp/src/index.tsx:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { FluentProvider, teamsLightTheme } from '@fluentui/react-components';
5 |
6 | import App from './App';
7 |
8 | import './App.css';
9 |
10 | import { createRoot } from 'react-dom/client';
11 | const container = document.getElementById('root');
12 | const root = createRoot(container!);
13 |
14 | root.render(
15 |
16 |
17 |
18 | )
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Request/CreateChatParameters.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | using System.Text.Json.Serialization;
4 |
5 | namespace CopilotChat.WebApi.Models.Request;
6 |
7 | ///
8 | /// Parameters for creating a new chat session.
9 | ///
10 | public class CreateChatParameters
11 | {
12 | ///
13 | /// Title of the chat.
14 | ///
15 | [JsonPropertyName("title")]
16 | public string? Title { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/redux/app/hooks.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import type { TypedUseSelectorHook } from 'react-redux';
5 | import { useDispatch, useSelector } from 'react-redux';
6 | import type { AppDispatch, RootState } from './store';
7 |
8 | // Use throughout your app instead of plain `useDispatch` and `useSelector`
9 | export const useAppDispatch: () => AppDispatch = useDispatch;
10 | export const useAppSelector: TypedUseSelectorHook = useSelector;
11 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Options/FrontendOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Options;
5 |
6 | ///
7 | /// Configuration options to be relayed to the frontend.
8 | ///
9 | public sealed class FrontendOptions
10 | {
11 | public const string PropertyName = "Frontend";
12 |
13 | ///
14 | /// Client ID for the frontend
15 | ///
16 | public string AadClientId { get; set; } = string.Empty;
17 | }
18 |
--------------------------------------------------------------------------------
/src/chat-copilot/shared/MemoryConfiguration.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.Shared;
5 |
6 | ///
7 | /// Configuration constants for kernel memory.
8 | ///
9 | public static class MemoryConfiguration
10 | {
11 | public const string KernelMemorySection = "KernelMemory";
12 | public const string ServicesSection = "Services";
13 | public const string OrchestrationTypeDistributed = "Distributed";
14 | public const string NoneType = "None";
15 | }
16 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 |
5 | {
6 | "name": "Debug CopilotChatWebApi",
7 | "type": "coreclr",
8 | "preLaunchTask": "build (CopilotChatWebApi)",
9 | "request": "launch",
10 | "program": "${workspaceFolder}/webapi/bin/Debug/net6.0/CopilotChatWebApi.dll",
11 | "cwd": "${workspaceFolder}/webapi",
12 | "env": {
13 | "ASPNETCORE_ENVIRONMENT": "Development"
14 | },
15 | }
16 | ]
17 | }
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/models/PlanExecutionMetadata.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { PlanType } from './Plan';
5 |
6 | // Metadata about plan execution.
7 | export interface PlanExecutionMetadata {
8 | // Steps taken execution stat.
9 | stepsTaken: string;
10 |
11 | // Time taken to fulfil the goal.
12 | timeTaken: string;
13 |
14 | // Functions used execution stat.
15 | functionsUsed: string;
16 |
17 | // Planner type.
18 | plannerType: PlanType;
19 | }
20 |
--------------------------------------------------------------------------------
/src/challenge-home/webapp/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | Challenges
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "msedge",
9 | "request": "launch",
10 | "name": "Launch Edge against localhost",
11 | "url": "http://localhost:3000",
12 | "webRoot": "${workspaceFolder}"
13 | }
14 | ]
15 | }
--------------------------------------------------------------------------------
/src/picture-submission/webapp/src/libs/models/SubmissionStatus.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export enum ReviewStatus {
5 | READY = "ready",
6 | REVIEWING = "reviewing",
7 | REVIEWED = "reviewed",
8 | }
9 |
10 | export interface ScoringResultResponse {
11 | passed: boolean;
12 | message: string;
13 | flag: string | null;
14 | }
15 |
16 | export interface SubmissionStatus {
17 | picture_id: string;
18 | status: ReviewStatus;
19 | scoring_result: ScoringResultResponse | null;
20 | }
--------------------------------------------------------------------------------
/src/challenge-home/webapp/public/data.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "1",
4 | "name": "Challenge Name",
5 | "description": "challenge description goes here",
6 | "category": "Responsible AI"
7 | },
8 | {
9 | "id": "2",
10 | "name": "Challenge Name2",
11 | "description": "challenge description goes here, challenge description goes herechallenge description goes herechallenge description goes herechallenge description goes herechallenge description goes herechallenge description goes herechallenge description goes here",
12 | "category": "Responsible AI"
13 | }
14 | ]
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Options/FileSystemOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.ComponentModel.DataAnnotations;
5 |
6 | namespace CopilotChat.WebApi.Options;
7 |
8 | ///
9 | /// File system storage configuration.
10 | ///
11 | public class FileSystemOptions
12 | {
13 | ///
14 | /// Gets or sets the file path for persistent file system storage.
15 | ///
16 | [Required, NotEmptyOrWhitespace]
17 | public string FilePath { get; set; } = string.Empty;
18 | }
19 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/index.css:
--------------------------------------------------------------------------------
1 | :root {
2 | font-synthesis: none;
3 | text-rendering: optimizeLegibility;
4 | -webkit-font-smoothing: antialiased;
5 | -moz-osx-font-smoothing: grayscale;
6 | -webkit-text-size-adjust: 100%;
7 | }
8 |
9 | body {
10 | margin: 0;
11 | overscroll-behavior: none;
12 | }
13 |
14 | html,
15 | body,
16 | #root,
17 | #root > .app-container {
18 | height: 100%;
19 | }
20 |
21 | ::-webkit-scrollbar {
22 | width: 0.4rem;
23 | }
24 | ::-webkit-scrollbar-thumb {
25 | border-radius: 12px;
26 | visibility: 'hidden';
27 | }
28 |
--------------------------------------------------------------------------------
/src/chat-copilot/shared/CopilotChatShared.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CopilotChat.Shared
5 | net6.0
6 | LatestMajor
7 | disable
8 | enable
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Request/Ask.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Collections.Generic;
5 | using System.ComponentModel.DataAnnotations;
6 | using System.Linq;
7 | using CopilotChat.WebApi.Options;
8 |
9 | namespace CopilotChat.WebApi.Models.Request;
10 |
11 | public class Ask
12 | {
13 | [Required, NotEmptyOrWhitespace]
14 | public string Input { get; set; } = string.Empty;
15 |
16 | public IEnumerable> Variables { get; set; } = Enumerable.Empty>();
17 | }
18 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Response/AuthErrorResponse.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Text.Json.Serialization;
5 |
6 | namespace CopilotChat.WebApi.Models.Response;
7 |
8 | public class AuthErrorResponse
9 | {
10 | [JsonPropertyName("auth_type")]
11 | public string AuthType { get; set; } = string.Empty;
12 |
13 | [JsonPropertyName("error")]
14 | public string Error { get; set; } = string.Empty;
15 |
16 | [JsonPropertyName("redirect_uri")]
17 | public string RedirectUri { get; set; } = string.Empty;
18 | }
19 |
--------------------------------------------------------------------------------
/src/chat-score/webapi/server/keys.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 |
4 | REDIS_CONNECTION_COUNT = "connection.count"
5 | REDIS_CONNECTION_SET = "connection.set"
6 | REDIS_CONNECTION_COUNT_KEY = "connection."
7 | REDIS_CONNECTION_POOL = "connection.pool"
8 |
9 | REDIS_CONVERSATION_QUEUE = "conversation.queue"
10 | REDIS_CONVERSATION_COUNT = "conversation.count"
11 | REDIS_CONVERSATION_ASSIGNMENT = "conversation.assignment"
12 | REDIS_CONVERSATION_KEY = "conversation."
13 | REDIS_CONVERSATION_TTL_KEY = "conversation.key.ttl."
14 |
15 | REDIS_LOCK_NAME = "lock"
--------------------------------------------------------------------------------
/docker/chat-copilot/plugins/rce-plugin/Dockerfile:
--------------------------------------------------------------------------------
1 | # docker build -f docker/plugins/rce-plugin/Dockerfile -t rce-plugin .
2 |
3 | FROM mcr.microsoft.com/devcontainers/python:dev-3.12-bullseye
4 |
5 | RUN adduser --system --no-create-home coderunner
6 |
7 | WORKDIR /app
8 | COPY src/chat-copilot/plugins/rce-plugin/requirements.txt .
9 | RUN pip install --no-cache-dir -r requirements.txt
10 | COPY src/chat-copilot/plugins/rce-plugin .
11 |
12 | RUN sed -i "s/localhost:5000/rce-challenge-service:8000/g" static/.well-known/ai-plugin.json
13 |
14 | USER coderunner
15 | EXPOSE 5000
16 | CMD [ "python", "app.py" ]
17 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Storage/MemoryTags.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Models.Storage;
5 |
6 | ///
7 | /// Tag names for kernel memory.
8 | ///
9 | internal static class MemoryTags
10 | {
11 | ///
12 | /// Associates memory with a specific chat
13 | ///
14 | public const string TagChatId = "chatid";
15 |
16 | ///
17 | /// Associates memory with specific type.
18 | ///
19 | public const string TagMemory = "memory";
20 | }
21 |
--------------------------------------------------------------------------------
/src/chat-score/webapp/src/reportWebVitals.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { ReportHandler } from 'web-vitals';
5 |
6 | const reportWebVitals = (onPerfEntry?: ReportHandler) => {
7 | if (onPerfEntry && onPerfEntry instanceof Function) {
8 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
9 | getCLS(onPerfEntry);
10 | getFID(onPerfEntry);
11 | getFCP(onPerfEntry);
12 | getLCP(onPerfEntry);
13 | getTTFB(onPerfEntry);
14 | });
15 | }
16 | };
17 |
18 | export default reportWebVitals;
19 |
--------------------------------------------------------------------------------
/src/chat-score/webapp/src/libs/services/BaseService.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | function ensureBackslash(url: string): string {
5 | if (!url.endsWith('/'))
6 | return url + '/';
7 | return url;
8 | }
9 |
10 | export const BackendServiceUrl =
11 | process.env.REACT_APP_BACKEND_URI == null || process.env.REACT_APP_BACKEND_URI.trim() === ''
12 | ? ensureBackslash(window.location.origin)
13 | : process.env.REACT_APP_BACKEND_URI;
14 |
15 | export const BackendServiceUrlPath = ensureBackslash(window.location.pathname) + "socket.io"
--------------------------------------------------------------------------------
/src/challenge-home/webapp/src/App.css:
--------------------------------------------------------------------------------
1 | #table-header-name {
2 | width: 20%;
3 | }
4 |
5 | #table-header-id {
6 | width: 5%;
7 | }
8 |
9 | #table-header-description {
10 | width: 50%;
11 | }
12 |
13 | body {
14 | margin: 0;
15 | }
16 |
17 | .App {
18 | display: flex;
19 | justify-content: center;
20 | height: 100vh;
21 | }
22 |
23 | .container {
24 | width: 80%;
25 | margin-top: 2em;
26 | }
27 |
28 | thead {
29 | position: sticky;
30 | top: 0;
31 | z-index: 1;
32 | }
33 |
34 | th {
35 | background-color: white;
36 | }
37 |
38 | .table-container {
39 | overflow: auto;
40 | max-height: 70vh;
41 | }
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/data/README.md:
--------------------------------------------------------------------------------
1 | # Tesseract OCR Support
2 |
3 | This API supports the ability to upload image file formats such as png, jpg and tiff via the [Tesseract](https://www.nuget.org/packages/Tesseract) nuget package.
4 | You will need to obtain one or more [tessdata language data files](https://github.com/tesseract-ocr/tessdata) such as `eng.traineddata` and add them to your `./data` directory or the location specified in the `Tesseract.FilePath` location in `./appsettings.json`.
5 |
6 | If you do not add any `.traineddata` files, you will receive a runtime exception when attempting to upload one of these image formats.
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/models/StepwiseStep.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export interface StepwiseStep {
5 | // The step number
6 | thought: string;
7 |
8 | // The action of the step
9 | action?: string;
10 |
11 | // The variables for the action
12 | action_variables?: Record;
13 |
14 | // The output of the action
15 | observation?: string;
16 |
17 | // The output of the system
18 | final_answer?: string;
19 |
20 | // The raw response from the action
21 | original_response: string;
22 | }
23 |
--------------------------------------------------------------------------------
/src/chat-score/webapp/src/redux/app/store.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { configureStore } from '@reduxjs/toolkit';
5 | import appReducer from '../features/app/appSlice';
6 |
7 | export const store = configureStore({
8 | reducer: {
9 | app: appReducer,
10 | },
11 | });
12 |
13 |
14 | // Infer the `RootState` and `AppDispatch` types from the store itself
15 | export type RootState = ReturnType
16 | // Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
17 | export type AppDispatch = typeof store.dispatch
--------------------------------------------------------------------------------
/src/picture-submission/webapp/src/reportWebVitals.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { ReportHandler } from 'web-vitals';
5 |
6 | const reportWebVitals = (onPerfEntry?: ReportHandler) => {
7 | if (onPerfEntry && onPerfEntry instanceof Function) {
8 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
9 | getCLS(onPerfEntry);
10 | getFID(onPerfEntry);
11 | getFCP(onPerfEntry);
12 | getLCP(onPerfEntry);
13 | getTTFB(onPerfEntry);
14 | });
15 | }
16 | };
17 |
18 | export default reportWebVitals;
19 |
--------------------------------------------------------------------------------
/docker/loadbalancer/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mcr.microsoft.com/oss/go/microsoft/golang:1.22-cbl-mariner2.0 AS builder
2 |
3 | WORKDIR /app
4 | COPY src/loadbalancer/go.mod ./
5 | RUN go mod download
6 |
7 | COPY src/loadbalancer/ ./
8 | RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /loadbalancer cmd/server/main.go
9 |
10 | FROM scratch
11 | # Add the required certificates
12 | COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
13 | COPY --from=builder /loadbalancer /loadbalancer
14 | COPY --from=builder /app/config-example.yaml /config.yaml
15 |
16 | EXPOSE 8080
17 | ENTRYPOINT [ "/loadbalancer" ]
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/components/views/Loading.tsx:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { Spinner } from '@fluentui/react-components';
5 | import { FC } from 'react';
6 | import { useSharedClasses } from '../../styles';
7 |
8 | interface ILoadingProps {
9 | text: string;
10 | }
11 |
12 | export const Loading: FC = ({ text }) => {
13 | const classes = useSharedClasses();
14 | return (
15 |
16 |
17 |
18 | );
19 | };
20 |
--------------------------------------------------------------------------------
/src/picture-submission/webapi/server/middleware/scoring_auth.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 |
4 | from functools import wraps
5 | from flask import request, Response, current_app as app
6 |
7 | from server.settings import CONFIG_SCORING_SETTINGS, CONFIG_SCORING_KEY
8 |
9 | def scoring_auth(f):
10 | @wraps(f)
11 | def wrapper(*args, **kwargs):
12 | if request.headers.get("x-scoring-key") != app.config[CONFIG_SCORING_SETTINGS][CONFIG_SCORING_KEY]:
13 | return Response("Unauthorized", status=401)
14 | return f(*args, **kwargs)
15 | return wrapper
--------------------------------------------------------------------------------
/src/picture-submission/webapp/src/redux/app/store.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { configureStore } from '@reduxjs/toolkit';
5 | import appReducer from '../features/app/appSlice';
6 |
7 | export const store = configureStore({
8 | reducer: {
9 | app: appReducer,
10 | },
11 | });
12 |
13 |
14 | // Infer the `RootState` and `AppDispatch` types from the store itself
15 | export type RootState = ReturnType
16 | // Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
17 | export type AppDispatch = typeof store.dispatch
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/assets/custom.d.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | declare module '*.svg' {
5 | import * as React from 'react';
6 |
7 | export const ReactComponent: React.FunctionComponent & { title?: string }>;
8 |
9 | const src: string;
10 | export default src;
11 | }
12 | declare module '*.png' {
13 | import * as React from 'react';
14 |
15 | export const ReactComponent: React.FunctionComponent & { title?: string }>;
16 |
17 | const src: string;
18 | export default src;
19 | }
20 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/models/ChatSession.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { IChatMessage } from './ChatMessage';
5 |
6 | export interface IChatSession {
7 | id: string;
8 | title: string;
9 | systemDescription: string;
10 | memoryBalance: number;
11 | enabledPlugins: string[];
12 | locked: boolean;
13 | ragDocument?: string;
14 | ragUserInput?: string;
15 | maxTurnReached: boolean;
16 | }
17 |
18 | export interface ICreateChatSessionResponse {
19 | chatSession: IChatSession;
20 | initialBotMessage: IChatMessage;
21 | }
22 |
--------------------------------------------------------------------------------
/src/loadbalancer/internal/config/keys.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | package config
5 |
6 | //Keys that are used in the config file
7 |
8 | const CReverseProxyHost = "reverseProxy.host"
9 | const CReverseProxyPort = "reverseProxy.port"
10 | const CReverseProxyTimeout = "reverseProxy.timeout" //Timeout in seconds
11 | const CReverseProxyTokenCutoff = "reverseProxy.tokenCutoff" //The number of minimum tokens that a model needs to have to make a request to it.
12 |
13 | const CReverseProxyAuthKey = "reverseProxy.authKey" //The key that is used to authenticate the requests
14 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/redux/features/users/usersSlice.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { createSlice, PayloadAction } from '@reduxjs/toolkit';
5 | import { initialState, Users, UsersState } from './UsersState';
6 |
7 | export const usersSlice = createSlice({
8 | name: 'users',
9 | initialState,
10 | reducers: {
11 | setUsers: (state: UsersState, action: PayloadAction) => {
12 | state.users = action.payload;
13 | },
14 | },
15 | });
16 |
17 | export const { setUsers } = usersSlice.actions;
18 |
19 | export default usersSlice.reducer;
20 |
--------------------------------------------------------------------------------
/docker/ctfd/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ctfd/ctfd:3.7.6
2 | RUN pip install psycopg2-binary
3 |
4 | # Adding the update_challenges.py script to the container
5 | COPY update_challenges.py /opt/CTFd/update_challenges.py
6 | COPY utils/challenges/__init__.py /opt/CTFd/CTFd/utils/challenges/__init__.py
7 | COPY utils/decorators/__init__.py /opt/CTFd/CTFd/utils/decorators/__init__.py
8 | COPY challenges_append.js /opt/CTFd/challenges_append.js
9 |
10 | # Append the challenges_append.js script to the challenges.js file
11 | RUN cat /opt/CTFd/challenges_append.js >> /opt/CTFd/CTFd/themes/core-beta/static/assets/challenges.0e43adc4.js && \
12 | rm /opt/CTFd/challenges_append.js
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Response/CtfdChallengeResponse.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Text.Json.Serialization;
5 |
6 | namespace CopilotChat.WebApi.Models.Response;
7 |
8 | public class CtfdChallengeResponse
9 | {
10 | [JsonPropertyName("name")]
11 | public string Name { get; set; } = string.Empty;
12 |
13 | [JsonPropertyName("id")]
14 | public int Id { get; set; } = 0;
15 |
16 | [JsonPropertyName("value")]
17 | public int Value { get; set; } = 0;
18 |
19 | [JsonPropertyName("solved_by_me")]
20 | public bool SolvedByMe { get; set; } = false;
21 | }
22 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/assets/strings.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export const COPY = {
5 | STEPWISE_RESULT_NOT_FOUND_REGEX: /(Result not found, review _stepsTaken to see what happened\.)\s+(\[{.*}])/g,
6 | CHAT_DELETED_MESSAGE: (chatName?: string) =>
7 | `Chat ${
8 | chatName ? `{${chatName}} ` : ''
9 | }has been removed by another user. You can still access the latest chat history for now. All chat content will be cleared once you refresh or exit the application.`,
10 | REFRESH_APP_ADVISORY: 'Please refresh the page to ensure you have the latest data.',
11 | };
12 |
--------------------------------------------------------------------------------
/src/challenge-home/webapp/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": [
5 | "dom",
6 | "dom.iterable",
7 | "esnext"
8 | ],
9 | "allowJs": true,
10 | "skipLibCheck": true,
11 | "esModuleInterop": true,
12 | "allowSyntheticDefaultImports": true,
13 | "strict": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "noFallthroughCasesInSwitch": true,
16 | "module": "esnext",
17 | "moduleResolution": "node",
18 | "resolveJsonModule": true,
19 | "isolatedModules": true,
20 | "noEmit": true,
21 | "jsx": "react-jsx"
22 | },
23 | "include": [
24 | "src"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Services/MemoryMigration/IChatMigrationMonitor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 |
7 | namespace CopilotChat.WebApi.Services.MemoryMigration;
8 |
9 | ///
10 | /// Contract for monitoring the status of chat memory migration.
11 | ///
12 | public interface IChatMigrationMonitor
13 | {
14 | ///
15 | /// Inspects the current state of affairs to determine the chat migration status.
16 | ///
17 | Task GetCurrentStatusAsync(CancellationToken cancellationToken = default);
18 | }
19 |
--------------------------------------------------------------------------------
/src/picture-submission/webapp/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": [
5 | "dom",
6 | "dom.iterable",
7 | "esnext"
8 | ],
9 | "allowJs": true,
10 | "skipLibCheck": true,
11 | "esModuleInterop": true,
12 | "allowSyntheticDefaultImports": true,
13 | "strict": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "noFallthroughCasesInSwitch": true,
16 | "module": "esnext",
17 | "moduleResolution": "node",
18 | "resolveJsonModule": true,
19 | "isolatedModules": true,
20 | "noEmit": true,
21 | "jsx": "react-jsx"
22 | },
23 | "include": [
24 | "src"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/src/chat-score/webapp/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": [
5 | "dom",
6 | "dom.iterable",
7 | "esnext",
8 | "webworker"
9 | ],
10 | "allowJs": true,
11 | "skipLibCheck": true,
12 | "esModuleInterop": true,
13 | "allowSyntheticDefaultImports": true,
14 | "strict": true,
15 | "forceConsistentCasingInFileNames": true,
16 | "noFallthroughCasesInSwitch": true,
17 | "module": "esnext",
18 | "moduleResolution": "node",
19 | "resolveJsonModule": true,
20 | "isolatedModules": true,
21 | "noEmit": true,
22 | "jsx": "react-jsx"
23 | },
24 | "include": [
25 | "src"
26 | ]
27 | }
--------------------------------------------------------------------------------
/src/chat-score/webapp/src/redux/features/app/AppState.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { ConversationReview } from "../../../libs/models/ChatMessage";
5 | import { ConversationStatus } from "../../../libs/models/StatusUpdate";
6 |
7 | export interface AppState {
8 | connectionCount: number;
9 | connected: boolean;
10 | conversationReview: ConversationReview | null;
11 | conversationQueue: ConversationStatus[];
12 | timeRemaining: number;
13 | }
14 |
15 | export const initialState: AppState = {
16 | connectionCount: 0,
17 | connected: false,
18 | conversationReview: null,
19 | conversationQueue: [],
20 | timeRemaining: 0
21 | };
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Services/IMaintenanceAction.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 |
7 | namespace CopilotChat.WebApi.Services;
8 |
9 | ///
10 | /// Defines discrete maintenance action responsible for both inspecting state
11 | /// and performing maintenance.
12 | ///
13 | public interface IMaintenanceAction
14 | {
15 | ///
16 | /// Calling site to initiate maintenance action.
17 | ///
18 | /// true if maintenance needed or in progress
19 | Task InvokeAsync(CancellationToken cancellation = default);
20 | }
21 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/utils/PlanUtils.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | // Use user intent, if available. If not, use user input.
5 | export const getPlanGoal = (description: string) => {
6 | const userIntentPrefix = 'User intent: ';
7 | const userIntentIndex = description.indexOf(userIntentPrefix);
8 | return userIntentIndex !== -1
9 | ? description.substring(userIntentIndex + userIntentPrefix.length).trim()
10 | : description
11 | .split('\n')
12 | .find((line: string) => line.startsWith('INPUT:'))
13 | ?.replace('INPUT:', '')
14 | .trim() ?? description;
15 | };
16 |
--------------------------------------------------------------------------------
/docker/chat-copilot/plugins/rce-plugin-target/Dockerfile:
--------------------------------------------------------------------------------
1 | # docker build -f docker/plugins/rce-plugin-target/Dockerfile -t rce-plugin-target .
2 |
3 | FROM mcr.microsoft.com/devcontainers/python:dev-3.12-bullseye
4 |
5 | RUN adduser --system --no-create-home coderunner
6 |
7 | WORKDIR /app
8 | COPY src/chat-copilot/plugins/rce-plugin/requirements.txt .
9 | RUN pip install --no-cache-dir -r requirements.txt
10 | COPY src/chat-copilot/plugins/rce-plugin .
11 |
12 | RUN sed -i "s/localhost:5000/rce-challenge-service:8000/g" static/.well-known/ai-plugin.json
13 |
14 | # Copy the second flag
15 | COPY docker/plugins/rce-plugin-target/flag.txt .
16 |
17 | USER coderunner
18 | EXPOSE 5000
19 | CMD [ "python", "app.py" ]
20 |
21 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Services/MemoryMigration/IChatMemoryMigrationService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 |
7 | namespace CopilotChat.WebApi.Services.MemoryMigration;
8 |
9 | ///
10 | /// Defines contract for migrating chat memory.
11 | ///
12 | public interface IChatMemoryMigrationService
13 | {
14 | ///
15 | /// Migrates all non-document memory to the kernel memory index.
16 | /// Subsequent/redunant migration is non-destructive/no-impact to migrated index.
17 | ///
18 | Task MigrateAsync(CancellationToken cancellationToken = default);
19 | }
20 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/components/views/Error.tsx:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { Subtitle2 } from '@fluentui/react-components';
5 | import { ErrorCircleRegular } from '@fluentui/react-icons';
6 | import { FC } from 'react';
7 | import { useSharedClasses } from '../../styles';
8 |
9 | interface IErrorProps {
10 | text: string;
11 | }
12 |
13 | export const Error: FC = ({ text }) => {
14 | const classes = useSharedClasses();
15 | return (
16 |
17 |
18 | {text}
19 |
20 | );
21 | };
22 |
--------------------------------------------------------------------------------
/src/chat-score/webapi/worker/common/conf.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 |
4 | import os
5 | from celery import Celery
6 | from server.environ import ENV_NAME_REDIS, REDIS_URL
7 | celery = Celery(__name__)
8 | celery.conf.broker_url = os.environ.get(ENV_NAME_REDIS, REDIS_URL)
9 | celery.conf.result_backend = os.environ.get(ENV_NAME_REDIS, REDIS_URL)
10 | celery.conf.beat_schedule = {
11 | 'tick-every-5s': {
12 | 'task': 'common.tick5s',
13 | 'schedule': 5.0,
14 | 'args': ()
15 | }
16 | }
17 | celery.conf.task_routes = {
18 | 'common.*':{'queue':'common'},
19 | }
20 | celery.conf.timezone = 'UTC'
21 | celery.conf.result_expires = 1800 #Results are kept for 30m
22 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Options/AzureSpeechOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Options;
5 |
6 | ///
7 | /// Configuration options for Azure speech recognition.
8 | ///
9 | public sealed class AzureSpeechOptions
10 | {
11 | public const string PropertyName = "AzureSpeech";
12 |
13 | ///
14 | /// Location of the Azure speech service to use (e.g. "South Central US")
15 | ///
16 | public string? Region { get; set; } = string.Empty;
17 |
18 | ///
19 | /// Key to access the Azure speech service.
20 | ///
21 | public string? Key { get; set; } = string.Empty;
22 | }
23 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Options/ChatArchiveSchemaInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.ComponentModel.DataAnnotations;
5 |
6 | namespace CopilotChat.WebApi.Options;
7 |
8 | ///
9 | /// Information on schema used to serialize chat archives.
10 | ///
11 | public record ChatArchiveSchemaInfo
12 | {
13 | ///
14 | /// The name of the schema.
15 | ///
16 | [Required, NotEmptyOrWhitespace]
17 | public string Name { get; init; } = "CopilotChat";
18 |
19 | ///
20 | /// The version of the schema.
21 | ///
22 | [Range(0, int.MaxValue)]
23 | public int Version { get; init; } = 1;
24 | }
25 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/services/MaintenanceService.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { BaseService } from './BaseService';
5 |
6 | export interface MaintenanceStatus {
7 | title: string | null;
8 | message: string | null;
9 | note: string | null | undefined;
10 | }
11 |
12 | export class MaintenanceService extends BaseService {
13 | public getMaintenanceStatus = async (accessToken: string) => {
14 | const result = await this.getResponseAsync(
15 | {
16 | commandPath: 'maintenanceStatus',
17 | },
18 | accessToken,
19 | );
20 |
21 | return result;
22 | };
23 | }
24 |
--------------------------------------------------------------------------------
/src/chat-score/webapi/worker/general.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation.
2 | # Licensed under the MIT License.
3 |
4 | from worker.common.conf import *
5 | from worker.common.imports import *
6 | from worker.tasks.tick import TickTask
7 | from server.models.lock import RedisLock
8 | from server.keys import REDIS_LOCK_NAME
9 |
10 | lock = RedisLock(r, REDIS_LOCK_NAME)
11 | tick_task = TickTask(r, lock, socket_io)
12 |
13 | @worker_ready.connect
14 | def init_worker(**kwargs):
15 | tick_task.worker_ready(kwargs["sender"].controller.concurrency)
16 |
17 | @worker_shutting_down.connect
18 | def stop_worker(**kwargs):
19 | tick_task.worker_stop()
20 |
21 | @celery.task(name="common.tick5s")
22 | def ticks5s():
23 | tick_task.tick()
--------------------------------------------------------------------------------
/src/picture-submission/webapp/src/redux/features/app/AppState.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { ChallengeSettings } from "../../../libs/models/ChallengeSettings";
5 | import { ReviewStatus, SubmissionStatus } from "../../../libs/models/SubmissionStatus";
6 |
7 | export interface AppState {
8 | challengeSettings: ChallengeSettings;
9 | status: SubmissionStatus;
10 | picture: string | null;
11 | }
12 |
13 | export const initialState: AppState = {
14 | challengeSettings: {
15 | id: 0,
16 | name: '',
17 | description: '',
18 | },
19 | status: {
20 | picture_id: '',
21 | status: ReviewStatus.READY,
22 | scoring_result: null,
23 | },
24 | picture: null,
25 | }
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Options/PluginOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 |
6 | namespace CopilotChat.WebApi.Options;
7 |
8 | ///
9 | /// Option for a single plugin.
10 | ///
11 | public class Plugin
12 | {
13 | ///
14 | /// The name of the plugin.
15 | ///
16 | public string Name { get; set; } = string.Empty;
17 |
18 | ///
19 | /// The url of the plugin.
20 | ///
21 | public Uri ManifestDomain { get; set; } = new Uri("http://localhost");
22 |
23 | ///
24 | /// The key of the plugin.
25 | ///
26 | public string Key { get; set; } = string.Empty;
27 | }
28 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Services/ITelemetryService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Services;
5 |
6 | ///
7 | /// Interface for common telemetry events to track actions across the semantic kernel.
8 | ///
9 | public interface ITelemetryService
10 | {
11 | ///
12 | /// Creates a telemetry event when a function is executed.
13 | ///
14 | /// Name of the plugin
15 | /// Function name
16 | /// If the function executed successfully
17 | void TrackPluginFunction(string pluginName, string functionName, bool success);
18 | }
19 |
--------------------------------------------------------------------------------
/src/chat-copilot/plugins/http-plugin/wwwroot/.well-known/ai-plugin.json:
--------------------------------------------------------------------------------
1 | {
2 | "schema_version": "v1",
3 | "name_for_human": "Http Request",
4 | "name_for_model": "HttpRequest",
5 | "description_for_human": "Use this plugin to enable users make HTTP GET requests to websites.",
6 | "description_for_model": "Use this plugin to enable users make HTTP GET requests to websites. This plugin should only be used if the user passes in a URL to the model.",
7 | "auth": {
8 | "type": "none"
9 | },
10 | "api": {
11 | "type": "openapi",
12 | "url": "http://localhost:5084/swagger/v1/swagger.json"
13 | },
14 | "logo_url": "https://example.com/logo.png",
15 | "contact_email": "support@example.com",
16 | "legal_info_url": "http://www.example.com/legal"
17 | }
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/.env.example:
--------------------------------------------------------------------------------
1 | # Required Variables
2 | REACT_APP_BACKEND_URI=https://localhost:40443/
3 |
4 | # To enable HTTPS, uncomment the following variables
5 | # HTTPS="true"
6 | # Replace with your locally-trusted cert file
7 | # SSL_CRT_FILE=local-cert.crt
8 | # Replace with your locally-trusted cert key
9 | # SSL_KEY_FILE=local-cert.key
10 |
11 | # For CI and testing purposes only
12 | REACT_APP_TEST_USER_ACCOUNT1=
13 | REACT_APP_TEST_USER_PASSWORD1=
14 | REACT_APP_TEST_USER_ACCOUNT2=
15 | REACT_APP_TEST_USER_PASSWORD2=
16 |
17 | REACT_APP_TEST_JIRA_EMAIL=
18 | REACT_APP_TEST_JIRA_ACCESS_TOKEN=
19 | REACT_APP_TEST_JIRA_SERVER_URL=
20 |
21 | REACT_APP_TEST_GITHUB_ACCESS_TOKEN=
22 | REACT_APP_TEST_GITHUB_ACCOUNT_OWNER=
23 | REACT_APP_TEST_GITHUB_REPOSITORY_NAME=
--------------------------------------------------------------------------------
/src/chat-score/webapp/src/libs/models/Worker.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | export interface SocketWorkerRequest {
5 | type: string;
6 | isSocket: boolean;
7 | payload: any;
8 | }
9 |
10 | export interface SocketWorkerResponse {
11 | type: string;
12 | isSocket: boolean;
13 | payload: string | undefined;
14 | }
15 |
16 | export interface WorkerInitRequestPayload {
17 | baseServiceUrl: string;
18 | baseServiceUrlPath: string;
19 | }
20 |
21 | export enum WorkerRequestType {
22 | Shutdown = "shutdown", //Shutdown the worker and close the connection
23 | Init = "init",
24 | }
25 |
26 | export enum WorkerResponseType {
27 | ShutdownComplete = "shutdown_complete", //Worker has closed the connection
28 | }
--------------------------------------------------------------------------------
/src/chat-copilot/plugins/http-plugin/HttpPlugin.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 | true
12 | $(NoWarn);1591
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | PreserveNewest
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/loadbalancer/cmd/server/main.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | package main
5 |
6 | import (
7 | "loadbalancer/internal/config"
8 | service "loadbalancer/internal/services"
9 | "loadbalancer/internal/services/orchestrator"
10 | "loadbalancer/internal/services/reverseproxy"
11 | "loadbalancer/pkg/graceful"
12 | "log"
13 | )
14 |
15 | func main() {
16 | config.Init()
17 | graceful.Register(service.ShutdownAll, "Services")
18 | handleGraceful := graceful.ListenSIG()
19 |
20 | log.Printf("Starting services")
21 | registerServices()
22 | service.StartAll()
23 |
24 | <-handleGraceful
25 | }
26 |
27 | func registerServices() {
28 | service.Add(&reverseproxy.ReverseProxy{})
29 | service.Add(&orchestrator.Orchestrator{})
30 | }
31 |
--------------------------------------------------------------------------------
/src/chat-copilot/plugins/rce-plugin/static/.well-known/ai-plugin.json:
--------------------------------------------------------------------------------
1 | {
2 | "schema_version": "v1",
3 | "name_for_human": "Python Code Runner",
4 | "name_for_model": "Python Code Runner",
5 | "description_for_human": "Use this plugin to run Python code. The plugin will run the python code and answer with the output of the python code.",
6 | "description_for_model": "Use this plugin to run Python code. The plugin will run the python code and answer with the output of the python code.",
7 | "auth": {
8 | "type": "none"
9 | },
10 | "api": {
11 | "type": "openapi",
12 | "url": "http://localhost:5000/swagger/swagger.json"
13 | },
14 | "logo_url": "https://example.com/logo.png",
15 | "contact_email": "support@example.com",
16 | "legal_info_url": "http://www.example.com/legal"
17 | }
--------------------------------------------------------------------------------
/src/chat-copilot/webapp/src/libs/services/ScoringService.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { ManualScoringResponse } from "../models/Scoring";
5 | import { BaseService } from "./BaseService";
6 |
7 | export class ScoringService extends BaseService {
8 | public createManualScoring = async (chatId: string, messageIndex: number, accessToken: string): Promise => {
9 | const body = {
10 | chatId,
11 | messageIndex,
12 | };
13 |
14 | const result = await this.getResponseAsync(
15 | {
16 | commandPath: `chats/${chatId}/scoring/manual`,
17 | method: 'POST',
18 | body,
19 | },
20 | accessToken,
21 | );
22 |
23 | return result;
24 | }
25 | }
--------------------------------------------------------------------------------
/src/chat-score/webapp/src/index.tsx:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import ReactDOM from 'react-dom/client';
5 | import { Provider } from 'react-redux';
6 | import App from './App';
7 | import './index.css';
8 | import { store } from './redux/app/store';
9 | import reportWebVitals from './reportWebVitals';
10 |
11 |
12 | const root = ReactDOM.createRoot(
13 | document.getElementById('root') as HTMLElement
14 | );
15 | root.render(
16 |
17 |
18 |
19 | );
20 |
21 | // If you want to start measuring performance in your app, pass a function
22 | // to log results (for example: reportWebVitals(console.log))
23 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
24 | reportWebVitals();
25 |
--------------------------------------------------------------------------------
/src/picture-submission/webapp/src/index.tsx:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import ReactDOM from 'react-dom/client';
5 | import { Provider } from 'react-redux';
6 | import App from './App';
7 | import './index.css';
8 | import { store } from './redux/app/store';
9 | import reportWebVitals from './reportWebVitals';
10 |
11 | const root = ReactDOM.createRoot(
12 | document.getElementById('root') as HTMLElement
13 | );
14 | root.render(
15 |
16 |
17 |
18 | );
19 |
20 | // If you want to start measuring performance in your app, pass a function
21 | // to log results (for example: reportWebVitals(console.log))
22 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
23 | reportWebVitals();
24 |
--------------------------------------------------------------------------------
/docker/challenge-home/Dockerfile:
--------------------------------------------------------------------------------
1 | # builder
2 | FROM mcr.microsoft.com/devcontainers/javascript-node:20-bookworm AS builder-webapp
3 | ARG PAT
4 | WORKDIR /app
5 | COPY src/challenge-home/webapp/ .
6 | RUN yarn install \
7 | --prefer-offline \
8 | --frozen-lockfile \
9 | --non-interactive \
10 | --production=false
11 | RUN yarn build
12 |
13 | # python
14 | FROM mcr.microsoft.com/cbl-mariner/base/python:3
15 | WORKDIR /app
16 | RUN tdnf install -y ca-certificates-microsoft && tdnf clean all
17 | COPY src/challenge-home/webapi/ .
18 | RUN pip install --no-cache-dir --upgrade -r requirements.txt && \
19 | pip install gunicorn && \
20 | mkdir -p build
21 | COPY --from=builder-webapp /app/build /app/build
22 | COPY docker/challenge-home/entrypoint.py /app/entrypoint.py
23 | ENTRYPOINT ["python3", "-u", "entrypoint.py"]
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Models/Request/DocumentImportForm.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using Microsoft.AspNetCore.Http;
7 |
8 | namespace CopilotChat.WebApi.Models.Request;
9 |
10 | ///
11 | /// Form for importing a document from a POST Http request.
12 | ///
13 | public class DocumentImportForm
14 | {
15 | ///
16 | /// The file to import.
17 | ///
18 | public IEnumerable FormFiles { get; set; } = Enumerable.Empty();
19 |
20 | ///
21 | /// Flag indicating whether user has content safety enabled from the client.
22 | ///
23 | public bool UseContentSafety { get; set; } = false;
24 | }
25 |
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Plugins/Utils/PromptUtils.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using static CopilotChat.WebApi.Models.Storage.CopilotChatMessage;
5 |
6 | namespace CopilotChat.WebApi.Plugins.Utils;
7 |
8 | ///
9 | /// Utility methods for prompt generation.
10 | ///
11 | public static class PromptUtils
12 | {
13 | ///
14 | /// Convert a chat message to a string in the format of: "Role: Content".
15 | ///
16 | /// The role of the author of the message.
17 | /// The content of the message.
18 | /// A formatted chat message string.
19 | internal static string? FormatChatHistoryMessage(AuthorRoles role, string content) => $"{role}: {content}";
20 | }
21 |
--------------------------------------------------------------------------------
/src/chat-copilot/shared/Ocr/Tesseract/TesseractOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System.ComponentModel.DataAnnotations;
5 |
6 | namespace CopilotChat.Shared.Ocr.Tesseract;
7 |
8 | ///
9 | /// Configuration options for Tesseract OCR support.
10 | ///
11 | public sealed class TesseractOptions
12 | {
13 | public const string SectionName = "Tesseract";
14 |
15 | ///
16 | /// The file path where the Tesseract language file is stored (e.g. "./data")
17 | ///
18 | [Required]
19 | public string? FilePath { get; set; } = string.Empty;
20 |
21 | ///
22 | /// The language file prefix name (e.g. "eng")
23 | ///
24 | [Required]
25 | public string? Language { get; set; } = string.Empty;
26 | }
27 |
--------------------------------------------------------------------------------
/docker/chat-score/Dockerfile:
--------------------------------------------------------------------------------
1 | # docker build -f docker/chat-score/Dockerfile -t chat-score .
2 |
3 | FROM mcr.microsoft.com/devcontainers/javascript-node:20-bookworm AS builder-webapp
4 | ARG PAT
5 | WORKDIR /app
6 | COPY src/chat-score/webapp/package.json chat-score/webapp/package-lock.json* ./
7 | RUN npm ci
8 |
9 | COPY src/chat-score/webapp/ .
10 | RUN rm -f .env && \
11 | npm run build
12 |
13 | # python
14 | FROM mcr.microsoft.com/cbl-mariner/base/python:3
15 | WORKDIR /app
16 | RUN tdnf install -y ca-certificates-microsoft && tdnf clean all
17 | COPY src/chat-score/webapi/ .
18 | RUN pip install --no-cache-dir --upgrade -r requirements.txt && \
19 | pip install gunicorn && \
20 | mkdir -p build
21 | COPY --from=builder-webapp /app/build /app/build
22 | COPY docker/chat-score/entrypoint.py /app/entrypoint.py
23 | ENTRYPOINT ["python3", "-u", "entrypoint.py"]
--------------------------------------------------------------------------------
/src/chat-copilot/webapi/Auth/AuthType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | namespace CopilotChat.WebApi.Auth;
5 |
6 | ///
7 | /// Types of authentication used in the system.
8 | ///
9 | public enum AuthType
10 | {
11 | ///
12 | /// No authentication is required. The user is assigned a GUID in the cookie and is identified by that.
13 | ///
14 | None,
15 |
16 | ///
17 | /// Authentication is performed by CTFd. The platform validates the CTFd cookie and checks with the CTFd redis instance if the session exists.
18 | ///
19 | CTFd,
20 |
21 | ///
22 | /// Authentication is performed by the challenge home service. The cookie is validated by the instance.
23 | ///
24 | ChallengeHome
25 | }
26 |
--------------------------------------------------------------------------------
/src/challenge-home/webapp/src/App.tsx:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import { Body2, Title1 } from "@fluentui/react-text";
5 | import { SortControlled } from "./table";
6 |
7 | const styles: React.CSSProperties = {
8 | marginTop: "var(--spacingVerticalS)",
9 | };
10 |
11 | function App() {
12 | return (
13 |
14 |
15 | AI Red Teaming Playground Labs
16 |
17 | Welcome to the AI Red Teaming Playground Labs. You will find below the challenges that are available. You can try a challenge and come back here once the challenge is completed.
18 |