🐛 Bug fixes
This commit is contained in:
		| @@ -86,56 +86,76 @@ public class ThoughtProvider | ||||
|                 return JsonSerializer.Serialize(response.Posts, GrpcTypeHelper.SerializerOptions); | ||||
|             }, "search_posts", "Search posts by query from the Solar Network."), | ||||
|             KernelFunctionFactory.CreateFromMethod(async ( | ||||
|                 string? publisherId = null, | ||||
|                 string? realmId = null, | ||||
|                 int pageSize = 10, | ||||
|                 string? pageToken = null, | ||||
|                 string? orderBy = null, | ||||
|                 List<string>? categories = null, | ||||
|                 List<string>? tags = null, | ||||
|                 string? query = null, | ||||
|                 List<int>? types = null, | ||||
|                 string? afterIso = null, | ||||
|                 string? beforeIso = null, | ||||
|                 bool includeReplies = false, | ||||
|                 string? pinned = null, | ||||
|                 bool onlyMedia = false, | ||||
|                 bool shuffle = false | ||||
|             ) => | ||||
|             { | ||||
|                 var request = new ListPostsRequest | ||||
|                     string? publisherId = null, | ||||
|                     string? realmId = null, | ||||
|                     int pageSize = 10, | ||||
|                     string? pageToken = null, | ||||
|                     string? orderBy = null, | ||||
|                     List<string>? categories = null, | ||||
|                     List<string>? tags = null, | ||||
|                     string? query = null, | ||||
|                     List<int>? types = null, | ||||
|                     string? afterIso = null, | ||||
|                     string? beforeIso = null, | ||||
|                     bool includeReplies = false, | ||||
|                     string? pinned = null, | ||||
|                     bool onlyMedia = false, | ||||
|                     bool shuffle = false | ||||
|                 ) => | ||||
|                 { | ||||
|                     PublisherId = publisherId, | ||||
|                     RealmId = realmId, | ||||
|                     PageSize = pageSize, | ||||
|                     PageToken = pageToken, | ||||
|                     OrderBy = orderBy, | ||||
|                     Query = query, | ||||
|                     IncludeReplies = includeReplies, | ||||
|                     Pinned = !string.IsNullOrEmpty(pinned) && int.TryParse(pinned, out int p) ? (PostPinMode)p : default, | ||||
|                     OnlyMedia = onlyMedia, | ||||
|                     Shuffle = shuffle | ||||
|                 }; | ||||
|                 if (!string.IsNullOrEmpty(afterIso)) | ||||
|                 { | ||||
|                     request.After = | ||||
|                         Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(DateTimeOffset.Parse(afterIso) | ||||
|                             .ToUniversalTime()); | ||||
|                 } | ||||
|                     var request = new ListPostsRequest | ||||
|                     { | ||||
|                         PublisherId = publisherId, | ||||
|                         RealmId = realmId, | ||||
|                         PageSize = pageSize, | ||||
|                         PageToken = pageToken, | ||||
|                         OrderBy = orderBy, | ||||
|                         Query = query, | ||||
|                         IncludeReplies = includeReplies, | ||||
|                         Pinned = | ||||
|                             !string.IsNullOrEmpty(pinned) && int.TryParse(pinned, out int p) ? (PostPinMode)p : default, | ||||
|                         OnlyMedia = onlyMedia, | ||||
|                         Shuffle = shuffle | ||||
|                     }; | ||||
|                     if (!string.IsNullOrEmpty(afterIso)) | ||||
|                     { | ||||
|                         request.After = | ||||
|                             Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(DateTimeOffset.Parse(afterIso) | ||||
|                                 .ToUniversalTime()); | ||||
|                     } | ||||
|  | ||||
|                 if (!string.IsNullOrEmpty(beforeIso)) | ||||
|                 { | ||||
|                     request.Before = | ||||
|                         Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(DateTimeOffset.Parse(beforeIso) | ||||
|                             .ToUniversalTime()); | ||||
|                 } | ||||
|                     if (!string.IsNullOrEmpty(beforeIso)) | ||||
|                     { | ||||
|                         request.Before = | ||||
|                             Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(DateTimeOffset.Parse(beforeIso) | ||||
|                                 .ToUniversalTime()); | ||||
|                     } | ||||
|  | ||||
|                 if (categories != null) request.Categories.AddRange(categories); | ||||
|                 if (tags != null) request.Tags.AddRange(tags); | ||||
|                 if (types != null) request.Types_.AddRange(types.Select(t => (PostType)t)); | ||||
|                 var response = await _postClient.ListPostsAsync(request); | ||||
|                 return JsonSerializer.Serialize(response.Posts.Select(SnPost.FromProtoValue), GrpcTypeHelper.SerializerOptions); | ||||
|             }, "list_posts", "Get posts from the Solar Network with customizable filters.") | ||||
|                     if (categories != null) request.Categories.AddRange(categories); | ||||
|                     if (tags != null) request.Tags.AddRange(tags); | ||||
|                     if (types != null) request.Types_.AddRange(types.Select(t => (PostType)t)); | ||||
|                     var response = await _postClient.ListPostsAsync(request); | ||||
|                     return JsonSerializer.Serialize(response.Posts.Select(SnPost.FromProtoValue), | ||||
|                         GrpcTypeHelper.SerializerOptions); | ||||
|                 }, "list_posts", | ||||
|                 "Get posts from the Solar Network with customizable filters.\n" + | ||||
|                 "Parameters:\n" + | ||||
|                 "publisherId (optional, string: publisher ID to filter by)\n" + | ||||
|                 "realmId (optional, string: realm ID to filter by)\n" + | ||||
|                 "pageSize (optional, integer: posts per page, default 20)\n" + | ||||
|                 "pageToken (optional, string: pagination token)\n" + | ||||
|                 "orderBy (optional, string: field to order by)\n" + | ||||
|                 "categories (optional, array of strings: category slugs)\n" + | ||||
|                 "tags (optional, array of strings: tag slugs)\n" + | ||||
|                 "query (optional, string: search query, will search in title, description and body)\n" + | ||||
|                 "types (optional, array of integers: post types, use 0 for Moment, 1 for Article)\n" + | ||||
|                 "afterIso (optional, string: ISO date for posts after this date)\n" + | ||||
|                 "beforeIso (optional, string: ISO date for posts before this date)\n" + | ||||
|                 "includeReplies (optional, boolean: include replies, default false)\n" + | ||||
|                 "pinned (optional, string: pin mode as integer string, '0' for PublisherPage, '1' for RealmPage, '2' for ReplyPage)\n" + | ||||
|                 "onlyMedia (optional, boolean: only posts with media, default false)\n" + | ||||
|                 "shuffle (optional, boolean: shuffle results, default false)" | ||||
|             ) | ||||
|         ]); | ||||
|     } | ||||
|  | ||||
| @@ -149,7 +169,7 @@ public class ThoughtProvider | ||||
|                     FunctionChoiceBehavior = FunctionChoiceBehavior.Auto( | ||||
|                         options: new FunctionChoiceBehaviorOptions | ||||
|                         { | ||||
|                             AllowParallelCalls = true,  | ||||
|                             AllowParallelCalls = true, | ||||
|                             AllowConcurrentInvocation = true | ||||
|                         }) | ||||
|                 }; | ||||
| @@ -167,4 +187,4 @@ public class ThoughtProvider | ||||
|                 throw new InvalidOperationException("Unknown provider: " + ModelProviderType); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user