@@ -22,36 +22,29 @@ namespace GitHubSkills;
22
22
public class GitHubSkill
23
23
{
24
24
/// <summary>
25
- /// Parameter names.
26
- /// <see cref="ContextVariables"/>
25
+ /// Name of the repository repositoryBranch which will be downloaded and summarized.
27
26
/// </summary>
28
- public static class Parameters
29
- {
30
- /// <summary>
31
- /// Name of the repository repositoryBranch which will be downloaded and summarized.
32
- /// </summary>
33
- public const string RepositoryBranch = "repositoryBranch" ;
34
-
35
- /// <summary>
36
- /// The search string to match against the names of files in the repository.
37
- /// </summary>
38
- public const string SearchPattern = "searchPattern" ;
39
-
40
- /// <summary>
41
- /// Document file path.
42
- /// </summary>
43
- public const string FilePath = "filePath" ;
44
-
45
- /// <summary>
46
- /// Directory to which to extract compressed file's data.
47
- /// </summary>
48
- public const string DestinationDirectoryPath = "destinationDirectoryPath" ;
49
-
50
- /// <summary>
51
- /// Name of the memory collection used to store the code summaries.
52
- /// </summary>
53
- public const string MemoryCollectionName = "memoryCollectionName" ;
54
- }
27
+ public const string RepositoryBranchParamName = "repositoryBranch" ;
28
+
29
+ /// <summary>
30
+ /// The search string to match against the names of files in the repository.
31
+ /// </summary>
32
+ public const string SearchPatternParamName = "searchPattern" ;
33
+
34
+ /// <summary>
35
+ /// Document file path.
36
+ /// </summary>
37
+ public const string FilePathParamName = "filePath" ;
38
+
39
+ /// <summary>
40
+ /// Directory to which to extract compressed file's data.
41
+ /// </summary>
42
+ public const string DestinationDirectoryPathParamName = "destinationDirectoryPath" ;
43
+
44
+ /// <summary>
45
+ /// Name of the memory collection used to store the code summaries.
46
+ /// </summary>
47
+ public const string MemoryCollectionNameParamName = "memoryCollectionName" ;
55
48
56
49
/// <summary>
57
50
/// The max tokens to process in a single semantic function call.
@@ -110,17 +103,17 @@ public GitHubSkill(IKernel kernel, WebFileDownloadSkill downloadSkill, ILogger<G
110
103
[ SKFunction ( "Downloads a repository and summarizes the content" ) ]
111
104
[ SKFunctionName ( "SummarizeRepository" ) ]
112
105
[ SKFunctionInput ( Description = "URL of the GitHub repository to summarize" ) ]
113
- [ SKFunctionContextParameter ( Name = Parameters . RepositoryBranch ,
106
+ [ SKFunctionContextParameter ( Name = RepositoryBranchParamName ,
114
107
Description = "Name of the repository repositoryBranch which will be downloaded and summarized" ) ]
115
- [ SKFunctionContextParameter ( Name = Parameters . SearchPattern , Description = "The search string to match against the names of files in the repository" ) ]
108
+ [ SKFunctionContextParameter ( Name = SearchPatternParamName , Description = "The search string to match against the names of files in the repository" ) ]
116
109
public async Task SummarizeRepositoryAsync ( string source , SKContext context )
117
110
{
118
- if ( ! context . Variables . Get ( Parameters . RepositoryBranch , out string repositoryBranch ) || string . IsNullOrEmpty ( repositoryBranch ) )
111
+ if ( ! context . Variables . Get ( RepositoryBranchParamName , out string repositoryBranch ) || string . IsNullOrEmpty ( repositoryBranch ) )
119
112
{
120
113
repositoryBranch = "main" ;
121
114
}
122
115
123
- if ( ! context . Variables . Get ( Parameters . SearchPattern , out string searchPattern ) || string . IsNullOrEmpty ( searchPattern ) )
116
+ if ( ! context . Variables . Get ( SearchPatternParamName , out string searchPattern ) || string . IsNullOrEmpty ( searchPattern ) )
124
117
{
125
118
searchPattern = "*.md" ;
126
119
}
@@ -133,14 +126,14 @@ public async Task SummarizeRepositoryAsync(string source, SKContext context)
133
126
{
134
127
var repositoryUri = source . Trim ( new char [ ] { ' ' , '/' } ) ;
135
128
var context1 = new SKContext ( new ContextVariables ( ) , NullMemory . Instance , null , context . Log ) ;
136
- context1 . Variables . Set ( Parameters . FilePath , filePath ) ;
129
+ context1 . Variables . Set ( FilePathParamName , filePath ) ;
137
130
await this . _downloadSkill . DownloadToFileAsync ( $ "{ repositoryUri } /archive/refs/heads/{ repositoryBranch } .zip", context1 ) ;
138
131
139
132
ZipFile . ExtractToDirectory ( filePath , directoryPath ) ;
140
133
141
134
await this . SummarizeCodeDirectoryAsync ( directoryPath , searchPattern , repositoryUri , repositoryBranch , context ) ;
142
135
143
- context . Variables . Set ( Parameters . MemoryCollectionName , $ "{ repositoryUri } -{ repositoryBranch } ") ;
136
+ context . Variables . Set ( MemoryCollectionNameParamName , $ "{ repositoryUri } -{ repositoryBranch } ") ;
144
137
}
145
138
finally
146
139
{
0 commit comments