You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The other benefit of simple configuration and simple solutions, is that they're easy to implement. A perfect example
@@ -819,3 +785,57 @@ Incidentally as [llms.py UI](https://servicestack.net/posts/llms-py-ui) and AI C
819
785
**import/export** features to transfer your AI Chat History between them.
820
786
821
787
Checkout the [llms.py GitHub repo](https://github.com/ServiceStack/llms) for even more features.
788
+
789
+
## AI Chat History Persistence
790
+
791
+
Enabling chat history persistence allows you to maintain a complete audit trail of all AI interactions, track token consumption, monitor costs across providers and models, and analyze usage patterns over time that captures every
792
+
request and response flowing through AI Chat's UI, external OpenAI endpoints and internal `IChatStore` requests.
793
+
794
+
### Database Storage Options
795
+
796
+
ServiceStack provides two storage implementations to suit different deployment scenarios:
797
+
798
+
`DbChatStore` - A universal solution that stores chat history in a single table compatible with any RDBMS
799
+
[supported by OrmLite](https://docs.servicestack.net/ormlite/getting-started):
800
+
801
+
```csharp
802
+
services.AddSingleton<IChatStore,DbChatStore>();
803
+
```
804
+
805
+
`PostgresChatStore` - An optimized implementation for PostgreSQL that leverages monthly table partitioning for improved query performance and data management:
Both implementations utilize indexed queries with result limits to ensure consistent performance even as your chat history grows. The partitioned approach in PostgreSQL offers additional benefits for long-term data retention and archival strategies.
812
+
813
+
## Admin UI Analytics
814
+
815
+
Once chat history persistence is enabled, the Admin UI provides comprehensive analytics dashboards that deliver actionable insights into your AI infrastructure. The analytics interface offers multiple views to help you understand costs, optimize token usage, and monitor activity patterns across all configured AI providers and models.
816
+
817
+
The analytics dashboard includes three primary tabs:
818
+
819
+
-**Cost Analysis** - Track spending across providers and models with daily and monthly breakdowns
820
+
-**Token Usage** - Monitor input and output token consumption to identify optimization opportunities
821
+
-**Activity** - Review detailed request logs with full conversation history and metadata
822
+
823
+
These visualizations enable data-driven decisions about provider selection, model usage, and cost optimization strategies.
824
+
825
+
### Cost Analysis
826
+
827
+
The Cost Analysis tab provides financial visibility into your AI operations with interactive visualizations showing spending distribution across providers and models. Daily cost trends help identify usage spikes, while monthly aggregations reveal long-term patterns. Pie charts break down costs by individual models and providers, making it easy to identify your most expensive AI resources and opportunities for cost optimization.
The Token Usage tab tracks both input (prompt) and output (completion) tokens across all requests. Daily usage charts display token consumption trends over time, while model and provider breakdowns show which AI resources consume the most tokens. This granular visibility helps optimize prompt engineering, identify inefficient usage patterns, and forecast capacity requirements.
The Activity tab maintains a searchable log of all AI chat requests, displaying timestamps, models, providers, and associated costs. Clicking any request opens a detailed view showing the complete conversation including user prompts, AI responses, token counts, duration, and the full request payload. This audit trail is invaluable for debugging, quality assurance, and understanding how your AI features are being used in production.
0 commit comments