Skip to content

Commit 6a3086d

Browse files
committed
Refactor deserialization and embedding generation logic
Removed unused Newtonsoft.Json.Serialization directive. Replaced deserialization and embedding generation logic to use a context sentence with multiple properties. Added a placeholder comment for saving to Cosmos DB.
1 parent 7eab45c commit 6a3086d

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

azure-project-generator/ProcessFile.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
using Newtonsoft.Json.Linq;
77
using Newtonsoft.Json.Schema;
88
using Newtonsoft.Json.Schema.Generation;
9-
using Newtonsoft.Json.Serialization;
10-
using OpenAI.Chat;
119
using OpenAI.Embeddings;
1210

1311
namespace azure_project_generator
@@ -80,16 +78,13 @@ public async Task Run([BlobTrigger("certdata/{name}", Connection = "AzureWebJobs
8078
_logger.LogError($"An unexpected error occurred: {ex.Message}");
8179
}
8280

83-
84-
85-
// TODO generate embeddings
86-
87-
8881
var mappedServiceData = JsonConvert.DeserializeObject<MappedService>(content);
89-
await GenerateEmbeddings(mappedServiceData.CertificationName);
90-
91-
82+
83+
string contextSentence =
84+
$"The {mappedServiceData.CertificationCode} {mappedServiceData.CertificationName} certification includes the skill of {mappedServiceData.SkillName}. Within this skill, there is a focus on the topic of {mappedServiceData.TopicName}, particularly through the use of the service {mappedServiceData.ServiceName}.";
9285

86+
await GenerateEmbeddings(contextSentence);
87+
9388

9489
}
9590

@@ -101,6 +96,9 @@ private async Task GenerateEmbeddings(string content)
10196
_logger.LogInformation("Generating embedding...");
10297
Embedding embedding = await _embeddingClient.GenerateEmbeddingAsync(content).ConfigureAwait(false);
10398
_logger.LogInformation("Embedding created successfully.");
99+
// save to cosmos
100+
101+
104102
}
105103
catch (RequestFailedException ex)
106104
{
@@ -132,8 +130,5 @@ private void ValidateJsonContent(string content)
132130
_logger.LogInformation("JSON content is valid against the schema.");
133131
}
134132
}
135-
136-
137-
138133
}
139134
}

0 commit comments

Comments
 (0)