1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-09-08 08:39:53 +00:00

some fixes and display version

This commit is contained in:
Laura
2025-08-11 01:38:16 +02:00
parent d8ded61a09
commit 607e316f69
7 changed files with 145 additions and 12 deletions

88
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,88 @@
name: Build and Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [windows, linux]
goarch: [amd64, arm64]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.5'
- name: Generate Windows resources
if: matrix.goos == 'windows'
run: |
go install github.com/tc-hib/go-winres@latest
go-winres simply \
--manifest cli \
--product-name whiskr \
--original-filename whiskr.exe \
--icon static/favicon.ico \
--copyright "(c) 2025 coalaura" \
--file-description "AI story writing tool" \
--file-version "${{ github.ref_name }}" \
--arch "${{ matrix.goarch }}"
- name: Build ${{ matrix.goos }}_${{ matrix.goarch }}
shell: bash
run: |
mkdir -p build
[[ "${{ matrix.goos }}" == "windows" ]] && EXT=".exe" || EXT=""
GOOS=${{ matrix.goos }} \
GOARCH=${{ matrix.goarch }} \
CGO_ENABLED=0 \
go build \
-trimpath \
-buildvcs=false \
-ldflags "-s -w -X 'main.Version=${{ github.ref_name }}'" \
-o "build/whiskr${EXT}" .
cp -r static build/static
cp .example.env build/.env
tar -czvf build/whiskr_${{ github.ref_name }}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz -C build "whiskr${EXT}" static
rm -rf build/static build/.env "build/whiskr${EXT}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: whiskr_${{ github.ref_name }}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz
path: build/*
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: ./build
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
files: ./build/**
name: "Release ${{ github.ref_name }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -23,6 +23,7 @@ whiskr is a private, self-hosted web chat interface for interacting with AI mode
## TODO
- Statistics for messages (tps, token count, etc.)
- Retry button for assistant messages
- Import and export of chats
- Image and file attachments

View File

@@ -11,6 +11,8 @@ import (
"github.com/go-chi/chi/v5/middleware"
)
const Version = "dev"
var log = logger.New().DetectTerminal().WithOptions(logger.Options{
NoLevel: true,
})
@@ -27,8 +29,11 @@ func main() {
fs := http.FileServer(http.Dir("./static"))
r.Handle("/*", cache(http.StripPrefix("/", fs)))
r.Get("/-/models", func(w http.ResponseWriter, r *http.Request) {
RespondJson(w, http.StatusOK, models)
r.Get("/-/data", func(w http.ResponseWriter, r *http.Request) {
RespondJson(w, http.StatusOK, map[string]any{
"version": Version,
"models": models,
})
})
r.Post("/-/chat", HandleChat)

View File

@@ -68,6 +68,29 @@ body {
overflow: hidden;
}
#version {
position: absolute;
font-size: 12px;
font-style: italic;
top: 3px;
right: 6px;
color: #a5adcb;
}
#version a {
color: #a5adcb;
text-decoration: none;
}
body.loading #version {
font-size: 0;
animation: rotating 1.2s linear infinite;
background-image: url(icons/spinner.svg);
width: 16px;
height: 16px;
top: 6px;
}
#page {
display: flex;
flex-direction: column;
@@ -419,6 +442,7 @@ select {
margin-right: 4px;
}
body.loading #version,
.reasoning .toggle::before,
.reasoning .toggle::after,
#bottom,

View File

@@ -15,7 +15,9 @@
<title>whiskr</title>
</head>
<body>
<body class="loading">
<div id="version"></div>
<div id="page">
<div id="messages"></div>
<div id="chat">

View File

@@ -1,5 +1,6 @@
(() => {
const $messages = document.getElementById("messages"),
const $version = document.getElementById("version"),
$messages = document.getElementById("messages"),
$chat = document.getElementById("chat"),
$message = document.getElementById("message"),
$bottom = document.getElementById("bottom"),
@@ -509,18 +510,22 @@
}
}
async function loadModels() {
const modelList = await json("/-/models");
async function loadData() {
const data = await json("/-/data");
if (!modelList) {
alert("Failed to load models.");
if (!data) {
alert("Failed to load data.");
return [];
return false;
}
// render version
$version.innerHTML = `<a href="https://github.com/coalaura/whiskr" target="_blank">whiskr</a> <a href="https://github.com/coalaura/whiskr/releases/tag/${data.version}" target="_blank">${data.version}</a>`;
// render models
$model.innerHTML = "";
for (const model of modelList) {
for (const model of data.models) {
const el = document.createElement("option");
el.value = model.id;
@@ -536,7 +541,7 @@
dropdown($model, 4);
return modelList;
return data;
}
function restore(modelList) {
@@ -841,5 +846,9 @@
dropdown($prompt);
dropdown($reasoningEffort);
loadModels().then(restore);
loadData().then((data) => {
restore(data?.models || []);
document.body.classList.remove("loading");
});
})();

View File

@@ -35,6 +35,10 @@
return `<pre>${header}<code>${code.text}</code></pre>`;
},
link(link) {
return `<a href="${link.href}" target="_blank">${escapeHtml(link.text || link.href)}</a>`;
},
},
});