-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompt.py
More file actions
69 lines (42 loc) · 1.79 KB
/
prompt.py
File metadata and controls
69 lines (42 loc) · 1.79 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from openai import OpenAI
import os
import numpy as np
from dotenv import load_dotenv
load_dotenv()
os.environ["TOKENIZERS_PARALLELISM"] = "false"
openai_client = OpenAI()
OpenAI.api_key = os.getenv('OPENAI_API_KEY')
def get_embedding(sentence):
return model.encode(sentence)
def get_cosine_similarity(embedding1, embedding2):
return np.dot(embedding1, embedding2) / (np.linalg.norm(embedding1) * np.linalg.norm(embedding2))
def split_into_paragraphs(text):
paragraphs = text.split('\n\n')
return [para for para in paragraphs if len(para) > 40]
def get_most_relevant_embeddings(embeddings, query_embedding):
similarities = []
for e in embeddings:
sim = get_cosine_similarity(query_embedding, embeddings[e])
similarities.append((sim, e))
similarities.sort(reverse=True, key=lambda x: x[0])
return similarities[:10]
def query_model(website_data, resume_data):
context = f"""\n\nHere is some information about me:
{resume_data}
Here is the website of the company that I am interviewing with:
{website_data}
"""
prompt = f"""You are an expert at preparing for interviews at Big Tech companies. I am a Cybersecurity student that is preparing for interviews. Given the information about the company that I am interviewing with below, generate an agenda for a 30 minute interview with the company.
For each section of the agenda, include specific topics to discuss based on my resume and the company's website.
{context}
"""
print("PROMPT", prompt)
res = openai_client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user",
"content": prompt},
]
)
print(res.choices[0].message.content)
return res.choices[0].message.content