diff --git a/.gitignore b/.gitignore
index e85110a..c29f702 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,14 @@
reasons.bleve
visits.bleve
+# JetBrains / IntelliJ / GoLand project files
+.idea/
+*.iml
+# Optional: uncomment if build output dir used by IDE
+# out/
+
+# More granular (kept for clarity; .idea/ above already covers these)
+#.idea/**/workspace.xml
+#.idea/**/tasks.xml
+#.idea/**/shelf
+#.idea/**/dataSources/
+#.idea/**/libraries
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
index 58368e9..8a5a744 100644
--- a/.idea/dataSources.xml
+++ b/.idea/dataSources.xml
@@ -13,5 +13,17 @@
$ProjectFileDir$
+
+ postgresql
+ true
+ org.postgresql.Driver
+ jdbc:postgresql://vetrag.live:5432/ragdb
+
+
+
+
+
+ $ProjectFileDir$
+
\ No newline at end of file
diff --git a/.idea/data_source_mapping.xml b/.idea/data_source_mapping.xml
index 9dbc1ed..b672dea 100644
--- a/.idea/data_source_mapping.xml
+++ b/.idea/data_source_mapping.xml
@@ -1,6 +1,7 @@
+
\ No newline at end of file
diff --git a/handlechat_integration_test.go b/handlechat_integration_test.go
index 0b15de1..74c246a 100644
--- a/handlechat_integration_test.go
+++ b/handlechat_integration_test.go
@@ -8,6 +8,7 @@ import (
"net/http/httptest"
"sync"
"testing"
+ "time"
"github.com/gin-gonic/gin"
)
@@ -62,6 +63,17 @@ func (r *mapChatRepo) SaveLLMRawEvent(ctx context.Context, correlationID, phase,
r.rawEvents = append(r.rawEvents, struct{ CorrelationID, Phase, Raw string }{correlationID, phase, raw})
return nil
}
+func (r *mapChatRepo) ListLLMRawEvents(ctx context.Context, correlationID string, limit, offset int) ([]RawLLMEvent, error) {
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ var out []RawLLMEvent
+ for _, e := range r.rawEvents {
+ if e.CorrelationID == correlationID {
+ out = append(out, RawLLMEvent{CorrelationID: e.CorrelationID, Phase: e.Phase, RawJSON: e.Raw, CreatedAt: time.Now()})
+ }
+ }
+ return out, nil
+}
// testVisitDB2 replicates a minimal VisitDB for integration
// (avoids relying on real Bleve index)
diff --git a/main.go b/main.go
index 5bba265..0672e88 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ import (
"context"
"os"
"strconv"
+ "strings"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
@@ -97,15 +98,22 @@ func main() {
}
c.JSON(200, gin.H{"items": items, "pagination": gin.H{"limit": limit, "offset": offset, "count": len(items)}})
})
- // JSON: list raw LLM events for a correlation id
+ // JSON: list raw LLM events for a correlation id OR serve UI when no correlation_id provided
r.GET("/admin/chats/events", func(c *gin.Context) {
- if repo == nil {
- c.JSON(200, gin.H{"items": []RawLLMEvent{}, "pagination": gin.H{"limit": 0, "offset": 0, "count": 0}, "warning": "repository not configured"})
- return
- }
corr := c.Query("correlation_id")
if corr == "" {
- c.JSON(400, gin.H{"error": "missing correlation_id"})
+ if strings.Contains(c.GetHeader("Accept"), "application/json") {
+ c.JSON(400, gin.H{"error": "missing correlation_id"})
+ return
+ }
+ c.Status(200)
+ if err := uiAdminChatsTemplate.Execute(c.Writer, nil); err != nil {
+ logrus.Errorf("Failed to execute ui_admin_chats.html template: %v", err)
+ }
+ return
+ }
+ if repo == nil { // repository not configured, return empty JSON set for events
+ c.JSON(200, gin.H{"items": []RawLLMEvent{}, "pagination": gin.H{"limit": 0, "offset": 0, "count": 0}, "warning": "repository not configured"})
return
}
limit := 100
diff --git a/openrouter_integration_test.go b/openrouter_integration_test.go
index e999d36..1698893 100644
--- a/openrouter_integration_test.go
+++ b/openrouter_integration_test.go
@@ -42,7 +42,7 @@ func TestLLMClient_OpenRouterStyle_ExtractKeywords(t *testing.T) {
}))
defer ts.Close()
- llm := NewLLMClient("test-key", ts.URL+"/v1/chat/completions", "meta-llama/test")
+ llm := NewLLMClient("test-key", ts.URL+"/v1/chat/completions", "meta-llama/test", nil)
res, err := llm.ExtractKeywords(context.Background(), "kutya hasmenés")
if err != nil {
te(t, "unexpected error: %v", err)
@@ -77,7 +77,7 @@ func TestLLMClient_OpenRouterStyle_Error(t *testing.T) {
}))
defer ts.Close()
- llm := NewLLMClient("test-key", ts.URL+"/v1/chat/completions", "meta-llama/test")
+ llm := NewLLMClient("test-key", ts.URL+"/v1/chat/completions", "meta-llama/test", nil)
_, err := llm.ExtractKeywords(context.Background(), "test")
if err == nil || !contains(err.Error(), "Rate limit") {
te(t, "expected rate limit error, got: %v", err)