Last active
October 6, 2023 01:17
-
-
Save ecdedios/0bdbd25217b118a7bfb717efcd9e100e to your computer and use it in GitHub Desktop.
semantic kernel chatgpt flask
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
import semantic_kernel as sk | |
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion | |
def chatgpt(prompt): | |
kernel = sk.Kernel() | |
api_key, org_id = sk.openai_settings_from_dot_env() | |
kernel.add_text_completion_service("dv", OpenAIChatCompletion("gpt-3.5-turbo", api_key, org_id)) | |
with open('resume.txt', encoding='utf-8') as f: | |
lines = f.readlines() | |
user_input = ' '.join(lines) + ' ' + prompt | |
semantic_function = kernel.create_semantic_function(user_input) | |
response = semantic_function() | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment