-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Call Azure OpenAI for optimizing the experiences (#2)
Directly call the Azure Chat service to get the 3 best experiences. * Update the documentation * Add Dependabot configuration file
- Loading branch information
Showing
15 changed files
with
100 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from knack.help_files import helps | ||
|
||
|
||
helps['optimize'] = """ | ||
type: group | ||
short-summary: Commands for optimizing resumes. | ||
long-summary: | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import asyncio | ||
import logging | ||
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion, AzureChatPromptExecutionSettings | ||
from semantic_kernel.contents import ChatHistory | ||
from ...common.config import GLOBAL_CONFIG | ||
|
||
|
||
def optimize_experiences(experiences_file: str, | ||
requirements_file: str, | ||
output_file: str) -> None: | ||
""" | ||
Optimize the experiences based on the job requirements and | ||
save the results in the output file. | ||
:param experiences_file: the file containing the experiences | ||
:param requirements_file: the file containing the job requirements | ||
:param output_file: the output file | ||
""" | ||
|
||
asyncio.run(_optimize_experiences(experiences_file, requirements_file, output_file)) | ||
|
||
|
||
async def _optimize_experiences(experiences_file: str, | ||
requirements_file: str, | ||
output_file: str) -> None: | ||
logging.info('Optimize experiences') | ||
|
||
# read experiences and job requirements | ||
with open(experiences_file, 'r', encoding='utf-8') as file: | ||
experiences = file.read() | ||
with open(requirements_file, 'r', encoding='utf-8') as file: | ||
requirements = file.read() | ||
|
||
chat_completion_service = AzureChatCompletion( | ||
deployment_name=GLOBAL_CONFIG.get('azure_openai', 'deployment'), | ||
endpoint=GLOBAL_CONFIG.get('azure_openai', 'endpoint'), | ||
api_key=GLOBAL_CONFIG.get('azure_openai', 'api_key')) | ||
|
||
request_settings = AzureChatPromptExecutionSettings( | ||
max_tokens=1000, | ||
) | ||
|
||
system_message = """ | ||
You are an assistant that helps people find the best | ||
3 experiences based on the job requirements. The user | ||
will provide you with a list of experiences and a list | ||
of requirements. | ||
""" | ||
|
||
user_input = f"Requirements: {requirements}\n\n" \ | ||
f"Experiences: {experiences}" | ||
|
||
chat_history = ChatHistory(system_message=system_message) | ||
chat_history.add_user_message(user_input) | ||
|
||
response = await chat_completion_service.get_chat_message_content( | ||
chat_history=chat_history, | ||
settings=request_settings, | ||
) | ||
if response: | ||
with open(output_file, 'w', encoding='utf-8') as file: | ||
file.write(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import unittest | ||
|
||
|
||
class FooTests(unittest.TestCase): | ||
|
||
def test_foo(self) -> None: | ||
self.assertEqual('bar', 'bar') |
This file was deleted.
Oops, something went wrong.