-
Notifications
You must be signed in to change notification settings - Fork 0
/
genearate_users.py
72 lines (59 loc) · 2.32 KB
/
genearate_users.py
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
70
71
72
import numpy as np
import google.generativeai as palm
import pandas as pd
import os
import json
import re
import random
from faker import Faker
fake = Faker()
palm.configure(api_key='AIzaSyDnUxKaSdabi0rNjxdcKtSvSuKWE-zDkNo')
path = "C:/Users/limah/OneDrive/Desktop/nasaSpaceApp/users.json"
programming_skills = [
"Python", "JavaScript", "Java", "C++", "Ruby", "Swift", "PHP", "Go", "Rust", "SQL",
"C#", "Perl", "HTML/CSS", "Kotlin", "TypeScript", "Scala", "Matlab", "R", "Assembly"
]
space_skills = [
"Astrophysics", "Astronomy", "Space Exploration", "Rocket Science", "Planetary Science", "Astrobiology",
"Orbital Mechanics", "Astrochemistry", "Exoplanet Research", "Space Weather", "Telescope Operation"
]
general_skills = [
"Communication", "Problem Solving", "Time Management", "Teamwork", "Critical Thinking", "Leadership",
"Project Management", "Data Analysis", "Creativity", "Adaptability", "Networking", "Public Speaking"
]
def generate_user():
name = fake.name()
email = fake.email()
programming_skill = random.choice(programming_skills)
space_skill = random.choice(space_skills)
general_skill = random.choice(general_skills)
description = f"I am good at {programming_skill} and {space_skill} and {general_skill}"
return {
"Name": name,
"Email": email,
"Description": description
}
def get_embedding(skills):
model = "models/embedding-gecko-001"
x = skills
embedding = palm.generate_embeddings(model=model, text=x)
embedding = embedding['embedding']
return embedding
def save_skills(existing_data, name, skills, embedding, email):
# if existing_data == None:
# existing_data = pd.DataFrame()
# print("::yessss")
new_row_data = {'name': name, 'skills': skills, 'email' :email, 'embeddings' : f"{embedding}"}
new_row_df = pd.DataFrame(new_row_data, index=[0])
existing_data = pd.concat([existing_data, new_row_df], ignore_index=True)
existing_data.to_json(path)
# new_row_df.to_json(path, orient='records')
print("saved")
users = [generate_user() for _ in range(20)]
for idx, user in enumerate(users, start=1):
existing_data = pd.read_json(path)
skills =user["Description"]
name = user["Name"]
email = user["Email"]
embedding = get_embedding(skills)
save_skills(existing_data, name,skills, embedding, email)