Skip to content

Commit 9bc7681

Browse files
committed
changing scope from entire certification to just a skill so projects are more doable for beginners
1 parent 5dea23d commit 9bc7681

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

azure-project-generator/GenerateProject.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ public GenerateProject(ILogger<GenerateProject> logger, ContentGenerationService
2424
}
2525

2626
[Function("GenerateProject")]
27-
public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequestData req, string certificationCode,
28-
27+
public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequestData req, string certificationCode, string skillName,
2928
[CosmosDBInput(Connection = "CosmosDBConnection")] CosmosClient client)
3029
{
3130
var response = req.CreateResponse(HttpStatusCode.OK);
@@ -50,21 +49,21 @@ public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function
5049
using FeedIterator<CertificationService> resultSetIterator =
5150
client.GetContainer("AzureCertDB", "certvectors").GetItemQueryIterator<CertificationService>(queryDef);
5251

53-
string projectServices = "";
54-
string projectSkills = "";
52+
string projectService = "";
53+
string projectSkill = "";
54+
string topicName = "";
55+
56+
57+
CertificationService feedResponse = resultSetIterator.ReadNextAsync().Result.FirstOrDefault();
58+
59+
projectService += feedResponse.ServiceName + " ";
60+
projectSkill += feedResponse.SkillName + " ";
61+
topicName += feedResponse.TopicName + " ";
62+
5563

56-
while (resultSetIterator.HasMoreResults)
57-
{
58-
FeedResponse<CertificationService> feedResponse = resultSetIterator.ReadNextAsync().Result;
59-
foreach (var item in feedResponse)
60-
{
61-
projectServices += item.ServiceName + " ";
62-
projectSkills += item.SkillName + " ";
6364

64-
}
65-
}
6665

67-
string cloudProjectIdea = await _contentGenerationService.GenerateProjectIdeaAsync(projectSkills, projectServices);
66+
string cloudProjectIdea = await _contentGenerationService.GenerateProjectIdeaAsync(projectSkill, projectService, topicName);
6867

6968
response.Headers.Add("Content-Type", "application/json");
7069
await response.WriteStringAsync(cloudProjectIdea);

azure-project-generator/ProcessCertDataFile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ public async Task<CertificationProjectPromptOutput> Run([BlobTrigger("certdata/{
7676
}
7777
}
7878
}
79-
8079

80+
string contextSentence = _contentGenerationService.GenerateCertDataContextSentence(certification);
8181

82-
float[] cerificationCodeVector = await _contentGenerationService.GenerateEmbeddingsAsync(certification.CertificationCode);
82+
float[] cerificationCodeVector = await _contentGenerationService.GenerateEmbeddingsAsync(contextSentence);
8383

8484
var certificationDocument = CreateCertificationProjectPromptDocument(certification, cerificationCodeVector);
8585

azure-project-generator/services/ContentGenerationService.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
using Microsoft.Extensions.Logging;
44
using OpenAI.Embeddings;
55
using OpenAI.Chat;
6-
using System.Text.Json;
7-
using Microsoft.AspNetCore.Mvc;
8-
using Newtonsoft.Json;
96
using Newtonsoft.Json.Linq;
107

118
namespace azure_project_generator.services
@@ -26,7 +23,8 @@ public ContentGenerationService(ILogger<ContentGenerationService> logger, Embedd
2623
public string GenerateCertServiceContextSentence(CertificationService data) =>
2724
$"The {data.CertificationCode} {data.CertificationName} certification includes the skill of {data.SkillName}. Within this skill, there is a focus on the topic of {data.TopicName}, particularly through the use of the service {data.ServiceName}.";
2825

29-
26+
public string GenerateCertDataContextSentence(Certification data) =>
27+
$"The {data.CertificationCode} {data.CertificationName} certification includes the following skills: {string.Join(", ", data.SkillsMeasured.Select(s => s.Name))}.";
3028
public async Task<float[]> GenerateEmbeddingsAsync(string content)
3129
{
3230
try
@@ -48,12 +46,12 @@ public async Task<float[]> GenerateEmbeddingsAsync(string content)
4846
}
4947
}
5048

51-
public async Task<string> GenerateProjectIdeaAsync(string skills, string services)
49+
public async Task<string> GenerateProjectIdeaAsync(string skill, string service, string topic)
5250
{
5351
string userPrompt = $@"You are an expert cloud architect.
5452
Please generate a detailed project idea for a beginner-friendly weekend cloud solution
55-
based on the following Azure certification skills: {skills}.
56-
The project should utilize the following services: {services}.
53+
based on the following Azure certification skill: {skill} and topic: {topic}.
54+
The project should utilize the ONLY following services: {service}.
5755
The project should be small in scale, achievable over a weekend, and have a fun, creative name. Suitable for beginners. Cheap to run.
5856
The response must be formatted as valid JSON and include only the following fields:
5957
{{
@@ -68,7 +66,7 @@ public async Task<string> GenerateProjectIdeaAsync(string skills, string service
6866
""Step 5: Description of the fifth step""
6967
]
7068
}}
71-
Ensure that the project idea is practical, aligned with beginner-level skills, and leverages best practices in Azure architecture.";
69+
Ensure that the project idea is practical, aligned with beginner-level skills, and leverages best practices in Azure architecture. Small in scope";
7270

7371
try
7472
{

0 commit comments

Comments
 (0)