auto_wyzant/get_message.py

42 lines
2.6 KiB
Python

from openai import OpenAI
import os
from dotenv import load_dotenv
load_dotenv()
OPEN_AI_API_KEY = os.getenv("OPEN_AI_API_KEY")
client = OpenAI(api_key=OPEN_AI_API_KEY)
example_format = """
Hello NAME_OF_JOB_POSTER,
I see you're looking to get some support with WHAT_THEY_NEED_HELP_WITH, and I would be more than happy to help. My name is Taylor and I have helped many students succeed in TOPIC, and THEIR_SPECIFIC_TOPIC in particular can be tough. I'd be happy to provide intuitive, relatable explanations for these difficult concepts. When would you be available for an initial session?
I look forward to working with you!
Warm Regards,
Taylor
"""
"Things about me to consider include that I have a degree in mathematics, have worked as a data analyst and software developer, have over a decade of experience working as a tutor, teacher, and classroom instructor. I have extensive experiene with all level of mathematics, general computer science, html, python, javascript, physics, R, Jupyter, Data Science, Statistics, SAT, ACT, and more."
system_content = f"""
"You are an assistan whose goal it is to create a personalized message for a prospective client of a tutor based off a given job description, subject, and name of job poster. The job may or may not be posted by the student themselves. Your response should address the person who posted the job and take in relevant context from the job description to craft a meaningful message that will showcase the ability and excitement of the tutor to help the student with whatever the job description mentions. Some relevant information about the tutor is that I have a degree in mathematics, have worked as a data analyst and software developer, have over a decade of experience working as a tutor, teacher, and classroom instructor. I have extensive experiene with all level of mathematics, general computer science, html, python, javascript, physics, R, Jupyter, Data Science, Statistics, SAT, ACT, and more. A sample message that has been used to some success and can be used as a general template is as follows. {example_format}"
"""
def generate_custom_message(job_description, job_poster, subject):
completion = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": system_content},
{
"role": "user",
"content": f"Create a message based on the following. \n Job Description: {job_description} \n Job Poster: {job_poster} \n Subject: {subject}"
}
]
)
return completion.choices[0].message.content