forked from whitphx/streamlit-webrtc-article-tutorial-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_questions.py
21 lines (18 loc) · 906 Bytes
/
generate_questions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from langchain.chat_models import ChatOpenAI
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain.prompts import PromptTemplate
from langchain.llms import OpenAI
from langchain.output_parsers import PydanticOutputParser
from typing import List
import json
import streamlit as st
def generate_questions(recruitInfo, n_query):
instruction = f"You are a recruitment interviewer. Generate {n_query} questions which are likely to be asked in the interview at the following company. Please note that questions should be unique to the company:Please display only questions in a bullet point format."
template = instruction + "\n#company:\n{company}\n"
prompt = PromptTemplate(
template=template,
input_variables=["company"],
).format_prompt(company=json.dumps(recruitInfo))
llm = OpenAI(temperature=1)
output = llm(prompt.to_string())
return output