1
- using Azure ;
2
1
using azure_project_generator . models ;
3
2
using azure_project_generator . services ;
4
- using Microsoft . AspNetCore . Http ;
5
- using Microsoft . AspNetCore . Mvc ;
6
3
using Microsoft . Azure . Cosmos ;
7
4
using Microsoft . Azure . Functions . Worker ;
8
5
using Microsoft . Azure . Functions . Worker . Http ;
9
6
using Microsoft . Extensions . Logging ;
10
- using Newtonsoft . Json ;
11
7
using System . Net ;
12
8
13
9
namespace azure_project_generator
@@ -24,23 +20,16 @@ public GenerateProject(ILogger<GenerateProject> logger, ContentGenerationService
24
20
}
25
21
26
22
[ Function ( "GenerateProject" ) ]
27
- public async Task < HttpResponseData > Run ( [ HttpTrigger ( AuthorizationLevel . Function , "get" ) ] HttpRequestData req , string certificationCode ,
28
-
23
+ public async Task < HttpResponseData > Run ( [ HttpTrigger ( AuthorizationLevel . Function , "get" ) ] HttpRequestData req , string certificationCode , string skillName ,
29
24
[ CosmosDBInput ( Connection = "CosmosDBConnection" ) ] CosmosClient client )
30
25
{
31
26
var response = req . CreateResponse ( HttpStatusCode . OK ) ;
32
27
_logger . LogInformation ( "C# HTTP trigger function processed a request." ) ;
33
28
34
- var query = new QueryDefinition ( "SELECT * FROM c WHERE c.certificationCode = @certificationCode" )
35
- . WithParameter ( "@certificationCode" , certificationCode ) ;
36
-
37
- var iterator = client . GetContainer ( "AzureCertDB" , "projectpromptvectors" )
38
- . GetItemQueryIterator < CertificationProjectPromptDocument > ( query ) ;
39
-
40
-
41
- CertificationProjectPromptDocument certificationProjectPromptDocument = iterator . ReadNextAsync ( ) . Result . FirstOrDefault ( ) ;
42
-
43
- float [ ] projectPromptVector = certificationProjectPromptDocument . ProjectPromptVector ;
29
+
30
+ string projectPrompt = "I need a project idea for the certification exam " + certificationCode + " for the skill " + skillName ;
31
+
32
+ float [ ] projectPromptVector = _contentGenerationService . GenerateEmbeddingsAsync ( projectPrompt ) . Result ;
44
33
45
34
var queryDef = new QueryDefinition
46
35
( query : $ "SELECT c.serviceName, c.skillName, c.topicName, VectorDistance(c.contextVector,@embedding) " +
@@ -51,20 +40,17 @@ public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function
51
40
client . GetContainer ( "AzureCertDB" , "certvectors" ) . GetItemQueryIterator < CertificationService > ( queryDef ) ;
52
41
53
42
string projectServices = "" ;
54
- string projectSkills = "" ;
55
43
56
44
while ( resultSetIterator . HasMoreResults )
57
45
{
58
46
FeedResponse < CertificationService > feedResponse = resultSetIterator . ReadNextAsync ( ) . Result ;
59
47
foreach ( var item in feedResponse )
60
48
{
61
49
projectServices += item . ServiceName + " " ;
62
- projectSkills += item . SkillName + " " ;
63
-
64
50
}
65
51
}
66
52
67
- string cloudProjectIdea = await _contentGenerationService . GenerateProjectIdeaAsync ( projectSkills , projectServices ) ;
53
+ string cloudProjectIdea = await _contentGenerationService . GenerateProjectIdeaAsync ( projectServices , skillName ) ;
68
54
69
55
response . Headers . Add ( "Content-Type" , "application/json" ) ;
70
56
await response . WriteStringAsync ( cloudProjectIdea ) ;
0 commit comments