File size: 1,178 Bytes
30396cd
 
 
 
6d30494
 
 
 
 
0cae9a4
6d30494
 
 
 
 
 
 
 
 
 
 
0cae9a4
6d30494
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'''
This module contains the functions to create conversation objects for job description generation
'''

import os
import openai
from langchain.chat_models import ChatOpenAI
from langchain.memory import ConversationBufferMemory
from llm import generate_prompt, generate_conversation, predict
from constants import TEMPERATURE, MODEL_NAME
openai_api_key = os.environ['OPENAI_API_KEY']
openai.api_key = openai_api_key


def get_job_description_conversation():
    '''
    Generate a conversation object for job description generation
    '''
    prompt = generate_prompt(
        input_variables=['history', 'input'],
        template_file='templates/job_description_generation.txt')
    llm = ChatOpenAI(temperature=TEMPERATURE, openai_api_key=openai_api_key, model=MODEL_NAME)
    memory = ConversationBufferMemory(ai_prefix="JobGPT")
    conversation = generate_conversation(memory=memory, llm=llm, prompt=prompt)
    return conversation


def predict_job_description(input_text: str, conversation: object):
    '''
    Predict the next response from the conversation object
    '''
    response = predict(input_text=input_text, conversation=conversation)
    return response