Skip to content

aliencube/open-chat-playground

Repository files navigation

Icon for OpenChat Playground Open Chat Playground

Open Chat Playground (OCP) is a web UI that is able to connect virtually any LLM from any platform.

Prerequisites

Getting started

Get the repository ready

  1. Login to GitHub.

    gh auth login
  2. Check login status.

    gh auth status
  3. Fork this repository to your account and clone the forked repository to your local machine.

    gh repo fork aliencube/open-chat-playground --clone --default-branch-only
  4. Navigate to the cloned repository.

    cd open-chat-playground
  5. Get the repository root.

    # bash/zsh
    REPOSITORY_ROOT=$(git rev-parse --show-toplevel)
    # PowerShell
    $REPOSITORY_ROOT = git rev-parse --show-toplevel

Run on local machine

Use GitHub Models

  1. Make sure you are at the repository root.

    cd $REPOSITORY_ROOT
  2. Add GitHub Personal Access Token (PAT) for GitHub Models connection. Make sure you should replace {{YOUR_TOKEN}} with your GitHub PAT.

    # bash/zsh
    dotnet user-secrets --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp \
        set GitHubModels:Token "{{YOUR_TOKEN}}"
    # PowerShell
    dotnet user-secrets --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp `
        set GitHubModels:Token "{{YOUR_TOKEN}}"

    For more details about GitHub PAT, refer to the doc, Managing your personal access tokens.

  3. Run the app.

    dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- --connector-type GitHubModels
  4. Open your web browser, navigate to http://localhost:5280, and enter prompts.

Run in container

Build container

  1. Make sure you are at the repository root.

    cd $REPOSITORY_ROOT
  2. Build a container.

    docker build -f Dockerfile -t openchat-playground:latest .

Run container

Use GitHub Models
  1. Get GitHub PAT.

    # bash/zsh
    TOKEN=$(dotnet user-secrets --project ./src/OpenChat.PlaygroundApp list --json | \
              sed -n '/^\/\//d; p' | jq -r '."GitHubModels:Token"')
    # PowerShell
    $TOKEN = (dotnet user-secrets --project ./src/OpenChat.PlaygroundApp list --json | `
                Select-String -NotMatch '^//(BEGIN|END)' | ConvertFrom-Json).'GitHubModels:Token'
  2. Run the app.

    # From locally built container
    docker run -i --rm -p 8080:8080 openchat-playground:latest --connector-type GitHubModels --token $TOKEN
    # From GitHub Container Registry
    docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest --connector-type GitHubModels --token $TOKEN
  3. Open your web browser, navigate to http://localhost:8080, and enter prompts.

Run on Azure

  1. Make sure you are at the repository root.

    cd $REPOSITORY_ROOT
  2. Login to Azure.

    # Login to Azure Dev CLI
    azd auth login
  3. Check login status.

    # Azure Dev CLI
    azd auth login --check-status
  4. Run the following commands in order to provision and deploy the app.

    azd up

    NOTE: You will be asked to provide Azure subscription and location for deployment.

  5. Clean up all the resources.

    azd down --force --purge

Run tests

Build app

  1. Make sure you are at the repository root.

    cd $REPOSITORY_ROOT
  2. Build the app.

    dotnet restore && dotnet build

Unit tests

  1. Make sure you are at the repository root.

    cd $REPOSITORY_ROOT
  2. Run tests.

    dotnet test --filter "Category=UnitTest"

Integration tests

  1. Make sure you are at the repository root.

    cd $REPOSITORY_ROOT
  2. Install playwright.

    pwsh $REPOSITORY_ROOT/test/OpenChat.PlaygroundApp.Tests/bin/Debug/net{YOUR_VERSION}/playwright.ps1 install
  3. Run the app.

    dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp
  4. Run tests.

    # With LLM provider
    dotnet test --filter "Category=IntegrationTest"
    # Without LLM provider
    dotnet test --filter "Category=IntegrationTest & Category!=LLMRequired"

Configure GitHub Actions for CI/CD Pipeline

  1. Make sure you are at the repository root.

    cd $REPOSITORY_ROOT
  2. Make sure you've logged in to Azure.

    azd auth login --check-status
  3. Run pipeline config.

    azd pipeline config
  4. Answer the question below:

    • ? Select how to authenticate the pipeline to Azure πŸ‘‰ Federated Service Principal (SP + OIDC)
    • ? Would you like to commit and push your local changes to start the configured CI pipeline? πŸ‘‰ No
  5. Once the configuration is done, push a new commit to GitHub to run the GitHub Actions workflow.

Packages

No packages published

Contributors 17