WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
)
|
||||
|
||||
func TestBuildLangfuseGenerationOutput(t *testing.T) {
|
||||
toolCalls := []types.LLMToolCall{{ID: "call_1", Type: "function"}}
|
||||
|
||||
got := buildLangfuseGenerationOutput("", "", "tool_calls", toolCalls)
|
||||
want := map[string]interface{}{
|
||||
"content": "",
|
||||
"tool_calls": toolCalls,
|
||||
"finish_reason": "tool_calls",
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("output without reasoning = %#v; want %#v", got, want)
|
||||
}
|
||||
|
||||
got = buildLangfuseGenerationOutput("answer", "thinking", "stop", nil)
|
||||
want = map[string]interface{}{
|
||||
"content": "answer",
|
||||
"tool_calls": []types.LLMToolCall(nil),
|
||||
"finish_reason": "stop",
|
||||
"reasoning_content": "thinking",
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("output with reasoning = %#v; want %#v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSnapshotLangfuseToolCallsKeepsModelArguments(t *testing.T) {
|
||||
providerCalls := []types.LLMToolCall{{
|
||||
ID: "call_1",
|
||||
Function: types.FunctionCall{Name: "wiki_read_page", Arguments: `{"slugs":["res://0001"]}`},
|
||||
}}
|
||||
snapshot := snapshotLangfuseToolCalls(providerCalls)
|
||||
providerCalls[0].Function.Arguments = `{"slugs":["summary/uuid"]}`
|
||||
|
||||
if got := snapshot[0].Function.Arguments; got != `{"slugs":["res://0001"]}` {
|
||||
t.Fatalf("Langfuse snapshot was mutated to %s", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildLangfuseMessagesReasoningContent(t *testing.T) {
|
||||
msgs := buildLangfuseMessages([]Message{
|
||||
{Role: "assistant", ReasoningContent: "chain of thought", ToolCalls: []ToolCall{{ID: "tc1"}}},
|
||||
})
|
||||
if len(msgs) != 1 {
|
||||
t.Fatalf("len(messages) = %d; want 1", len(msgs))
|
||||
}
|
||||
if msgs[0]["reasoning_content"] != "chain of thought" {
|
||||
t.Fatalf("reasoning_content = %v; want chain of thought", msgs[0]["reasoning_content"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvertUsageIncludesPromptCacheCounters(t *testing.T) {
|
||||
got := convertUsage(&types.TokenUsage{
|
||||
PromptTokens: 1000, CompletionTokens: 50, TotalTokens: 1050,
|
||||
CacheReadTokens: 800, CacheWriteTokens: 100, CacheMissTokens: 200,
|
||||
})
|
||||
if got == nil {
|
||||
t.Fatal("convertUsage returned nil")
|
||||
}
|
||||
if got.CacheRead != 800 || got.CacheWrite != 100 || got.CacheMiss != 200 {
|
||||
t.Fatalf("cache usage = read:%d write:%d miss:%d", got.CacheRead, got.CacheWrite, got.CacheMiss)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user