Skip to content

Instantly share code, notes, and snippets.

@ecdedios
Last active October 6, 2023 01:17
Show Gist options
  • Save ecdedios/0bdbd25217b118a7bfb717efcd9e100e to your computer and use it in GitHub Desktop.
Save ecdedios/0bdbd25217b118a7bfb717efcd9e100e to your computer and use it in GitHub Desktop.
semantic kernel chatgpt flask
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