Skip to content

Latest commit

 

History

History
247 lines (183 loc) · 6.89 KB

File metadata and controls

247 lines (183 loc) · 6.89 KB

OpenChat Playground with GitHub Models

This page describes to run OpenChat Playground (OCP) with GitHub Models integration.

Get the repository root

  1. 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

  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 {{GH_PAT}} with your GitHub PAT.

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

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

  3. Run the app. The default model OCP uses is GPT-4o mini.

    # bash/zsh
    dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- \
        --connector-type GitHubModels
    # PowerShell
    dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- `
        --connector-type GitHubModels

    Alternatively, if you want to run with a different model, say Grok 3 mini, other than the default one, you can specify it as an argument:

    # bash/zsh
    dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- \
        --connector-type GitHubModels \
        --model xai/grok-3-mini
    # PowerShell
    dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- `
        --connector-type GitHubModels `
        --model xai/grok-3-mini
  4. Open your web browser, navigate to http://localhost:5280, and enter prompts.

Run in local 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 .
  3. 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'
  4. Run the app.

    # bash/zsh - From locally built container
    docker run -i --rm -p 8080:8080 openchat-playground:latest \
        --connector-type GitHubModels \
        --token $TOKEN
    # PowerShell - From locally built container
    docker run -i --rm -p 8080:8080 openchat-playground:latest `
        --connector-type GitHubModels `
        --token $TOKEN
    # bash/zsh - 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
    # PowerShell - 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

    Alternatively, if you want to run with a different model, say Grok 3 mini, other than the default one, you can specify it as an argument:

    # bash/zsh - From locally built container
    docker run -i --rm -p 8080:8080 openchat-playground:latest \
        --connector-type GitHubModels \
        --token $TOKEN \
        --model xai/grok-3-mini
    # PowerShell - From locally built container
    docker run -i --rm -p 8080:8080 openchat-playground:latest `
        --connector-type GitHubModels `
        --token $TOKEN `
        --model xai/grok-3-mini
    # bash/zsh - 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 \
        --model xai/grok-3-mini
    # PowerShell - 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 `
        --model xai/grok-3-mini
  5. 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. Initialize azd template.

    azd init

    NOTE: You will be asked to provide environment name for provisioning.

  5. 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'
  6. Set GitHub PAT to azd environment variables.

    azd env set GH_MODELS_TOKEN $TOKEN

    The default model OCP uses is GPT-4o mini. If you want to run with a different model, say Grok 3 mini, other than the default one, add it to azd environment variables.

    azd env set GH_MODELS_MODEL "xai/grok-3-mini"
  7. Set the connector type to GitHubModels.

    azd env set CONNECTOR_TYPE "GitHubModels"
  8. 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.

    Once deployed, you will be able to see the deployed OCP app URL.

  9. Open your web browser, navigate to the OCP app URL, and enter prompts.

  10. Clean up all the resources.

    azd down --force --purge