Skip to content

Version tracker, tracing enhancements and ui changes #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config/gni/devtools_grd_files.gni
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,6 @@ grd_files_bundled_sources = [
"front_end/panels/ai_chat/ui/PromptEditDialog.js",
"front_end/panels/ai_chat/ui/SettingsDialog.js",
"front_end/panels/ai_chat/ui/EvaluationDialog.js",
"front_end/panels/ai_chat/ui/components/TracingConfig.js",
"front_end/panels/ai_chat/ui/components/EvaluationConfig.js",
"front_end/panels/ai_chat/ui/components/VectorDatabaseConfig.js",
"front_end/panels/ai_chat/ui/components/ProviderConfig.js",
Expand All @@ -625,6 +624,8 @@ grd_files_bundled_sources = [
"front_end/panels/ai_chat/core/GraphHelpers.js",
"front_end/panels/ai_chat/core/StateGraph.js",
"front_end/panels/ai_chat/core/Logger.js",
"front_end/panels/ai_chat/core/Version.js",
"front_end/panels/ai_chat/core/VersionChecker.js",
"front_end/panels/ai_chat/LLM/LLMTypes.js",
"front_end/panels/ai_chat/LLM/LLMProvider.js",
"front_end/panels/ai_chat/LLM/LLMProviderRegistry.js",
Expand Down Expand Up @@ -665,6 +666,7 @@ grd_files_bundled_sources = [
"front_end/panels/ai_chat/ai_chat.js",
"front_end/panels/ai_chat/ai_chat_impl.js",
"front_end/panels/ai_chat/agent_framework/AgentRunner.js",
"front_end/panels/ai_chat/agent_framework/AgentSessionTypes.js",
"front_end/panels/ai_chat/agent_framework/ConfigurableAgentTool.js",
"front_end/panels/ai_chat/agent_framework/implementation/ConfiguredAgents.js",
"front_end/panels/ai_chat/common/MarkdownViewerUtil.js",
Expand Down
1 change: 1 addition & 0 deletions front_end/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ group("unittests") {
"models/workspace_diff:unittests",
"panels/accessibility:unittests",
"panels/ai_assistance:unittests",
"panels/ai_chat:unittests",
"panels/animation:unittests",
"panels/application:unittests",
"panels/application/components:unittests",
Expand Down
6 changes: 6 additions & 0 deletions front_end/panels/ai_chat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Optional: Uncomment the line below if you want to exclude the auto-generated Version.ts
# core/Version.ts

# Temporary files
*.tmp
*.log
23 changes: 21 additions & 2 deletions front_end/panels/ai_chat/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ devtools_module("ai_chat") {
"core/GraphHelpers.ts",
"core/StateGraph.ts",
"core/Logger.ts",
"core/Version.ts",
"core/VersionChecker.ts",
"LLM/LLMTypes.ts",
"LLM/LLMProvider.ts",
"LLM/LLMProviderRegistry.ts",
Expand All @@ -61,6 +63,7 @@ devtools_module("ai_chat") {
"tools/DocumentSearchTool.ts",
"agent_framework/ConfigurableAgentTool.ts",
"agent_framework/AgentRunner.ts",
"agent_framework/AgentSessionTypes.ts",
"agent_framework/implementation/ConfiguredAgents.ts",
"evaluation/framework/types.ts",
"evaluation/framework/judges/LLMEvaluator.ts",
Expand Down Expand Up @@ -90,7 +93,6 @@ devtools_module("ai_chat") {
"tracing/TracingProvider.ts",
"tracing/LangfuseProvider.ts",
"tracing/TracingConfig.ts",
"ui/components/TracingConfig.ts",
"ui/components/EvaluationConfig.ts",
"ui/components/VectorDatabaseConfig.ts",
"ui/components/ProviderConfig.ts",
Expand Down Expand Up @@ -124,7 +126,6 @@ _ai_chat_sources = [
"ui/PromptEditDialog.ts",
"ui/SettingsDialog.ts",
"ui/EvaluationDialog.ts",
"ui/components/TracingConfig.ts",
"ui/components/EvaluationConfig.ts",
"ui/components/VectorDatabaseConfig.ts",
"ui/components/ProviderConfig.ts",
Expand All @@ -142,6 +143,8 @@ _ai_chat_sources = [
"core/GraphHelpers.ts",
"core/StateGraph.ts",
"core/Logger.ts",
"core/Version.ts",
"core/VersionChecker.ts",
"LLM/LLMTypes.ts",
"LLM/LLMProvider.ts",
"LLM/LLMProviderRegistry.ts",
Expand All @@ -167,6 +170,7 @@ _ai_chat_sources = [
"tools/DocumentSearchTool.ts",
"agent_framework/ConfigurableAgentTool.ts",
"agent_framework/AgentRunner.ts",
"agent_framework/AgentSessionTypes.ts",
"agent_framework/implementation/ConfiguredAgents.ts",
"evaluation/framework/types.ts",
"evaluation/framework/judges/LLMEvaluator.ts",
Expand Down Expand Up @@ -276,3 +280,18 @@ devtools_entrypoint("meta") {

visibility = [ "../../entrypoints/*" ]
}

ts_library("unittests") {
testonly = true

sources = [
"common/utils.test.ts",
]

deps = [
":ai_chat",
"../../testing",
"../../core/sdk:bundle",
"../../generated:protocol",
]
}
11 changes: 11 additions & 0 deletions front_end/panels/ai_chat/LLM/OpenRouterProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ export class OpenRouterProvider extends LLMBaseProvider {
outputTokens: data.usage.completion_tokens,
totalTokens: data.usage.total_tokens
});

// Ensure usage data is preserved in rawResponse for tracing
if (!data.rawResponse) {
data.rawResponse = {};
}
data.rawResponse.usage = data.usage;
}

return data;
Expand All @@ -151,6 +157,11 @@ export class OpenRouterProvider extends LLMBaseProvider {
const result: LLMResponse = {
rawResponse: data
};

// Ensure usage data is available for tracing
if (data.usage && data.rawResponse) {
data.rawResponse.usage = data.usage;
}

if (!data?.choices || data.choices.length === 0) {
throw new Error('No choices in OpenRouter response');
Expand Down
Loading