66using MongoDB . Driver ;
77using BotSharp . Abstraction . Routing . Models ;
88using BotSharp . Abstraction . Repositories . Filters ;
9- using BotSharp . Abstraction . Utilities ;
10- using BotSharp . Abstraction . Conversations . Models ;
119
1210namespace BotSharp . Core . Repository ;
1311
@@ -789,33 +787,6 @@ public List<Conversation> GetLastConversations()
789787 . Select ( g => g . OrderByDescending ( x => x . CreatedTime ) . First ( ) )
790788 . ToList ( ) ;
791789 }
792-
793- public void AddExectionLogs ( string conversationId , List < string > logs )
794- {
795- if ( string . IsNullOrEmpty ( conversationId ) || logs . IsNullOrEmpty ( ) ) return ;
796-
797- var dir = Path . Combine ( _dbSettings . FileRepository , "conversations" , conversationId ) ;
798- if ( ! Directory . Exists ( dir ) )
799- {
800- Directory . CreateDirectory ( dir ) ;
801- }
802-
803- var file = Path . Combine ( dir , "execution.log" ) ;
804- File . AppendAllLines ( file , logs ) ;
805- }
806-
807- public List < string > GetExectionLogs ( string conversationId )
808- {
809- var logs = new List < string > ( ) ;
810- if ( string . IsNullOrEmpty ( conversationId ) ) return logs ;
811-
812- var dir = Path . Combine ( _dbSettings . FileRepository , "conversations" , conversationId ) ;
813- if ( ! Directory . Exists ( dir ) ) return logs ;
814-
815- var file = Path . Combine ( dir , "execution.log" ) ;
816- logs = File . ReadAllLines ( file ) ? . ToList ( ) ?? new List < string > ( ) ;
817- return logs ;
818- }
819790 #endregion
820791
821792 #region User
@@ -843,6 +814,35 @@ public void CreateUser(User user)
843814 }
844815 #endregion
845816
817+ #region Execution Log
818+ public void AddExecutionLogs ( string conversationId , List < string > logs )
819+ {
820+ if ( string . IsNullOrEmpty ( conversationId ) || logs . IsNullOrEmpty ( ) ) return ;
821+
822+ var dir = Path . Combine ( _dbSettings . FileRepository , "conversations" , conversationId ) ;
823+ if ( ! Directory . Exists ( dir ) )
824+ {
825+ Directory . CreateDirectory ( dir ) ;
826+ }
827+
828+ var file = Path . Combine ( dir , "execution.log" ) ;
829+ File . AppendAllLines ( file , logs ) ;
830+ }
831+
832+ public List < string > GetExecutionLogs ( string conversationId )
833+ {
834+ var logs = new List < string > ( ) ;
835+ if ( string . IsNullOrEmpty ( conversationId ) ) return logs ;
836+
837+ var dir = Path . Combine ( _dbSettings . FileRepository , "conversations" , conversationId ) ;
838+ if ( ! Directory . Exists ( dir ) ) return logs ;
839+
840+ var file = Path . Combine ( dir , "execution.log" ) ;
841+ logs = File . ReadAllLines ( file ) ? . ToList ( ) ?? new List < string > ( ) ;
842+ return logs ;
843+ }
844+ #endregion
845+
846846 #region LLM Completion Log
847847 public void SaveLlmCompletionLog ( LlmCompletionLog log )
848848 {
@@ -855,6 +855,7 @@ public void SaveLlmCompletionLog(LlmCompletionLog log)
855855 Directory . CreateDirectory ( logDir ) ;
856856 }
857857
858+ log . Id = Guid . NewGuid ( ) . ToString ( ) ;
858859 var index = GetLlmCompletionLogIndex ( logDir , log . MessageId ) ;
859860 var file = Path . Combine ( logDir , $ "{ log . MessageId } .{ index } .log") ;
860861 File . WriteAllText ( file , JsonSerializer . Serialize ( log , _options ) ) ;
0 commit comments