Spaces:
Runtime error
Runtime error
File size: 3,980 Bytes
4f8d404 8aae26a 4f8d404 8aae26a 4f8d404 8aae26a 4f8d404 8aae26a 4f8d404 8aae26a 4f8d404 |
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
import os
import streamlit as st
from dotenv import load_dotenv
from Bard import Chatbot
import asyncio
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
load_dotenv()
WEBSOCKET_TIMEOUT_MS = 10000
def get_token():
with st.form(key="BARD_API_form"):
st.markdown(
"## BARD API token \n Go to https://bard.google.com/ \n "
"- F12 for console \n "
"- Copy the values of the cookies: \n "
" - Session: Go to Application β Cookies β `__Secure-1PSID`. Copy the value of that cookie."
)
psid = st.text_input(label="Enter your __Secure-1PSID token")
psidts = st.text_input(label="Enter your __Secure-1PSIDTS token")
submit_button = st.form_submit_button(label="Submit")
return psid, psidts, submit_button
def prompt_letter():
"""
This function creates a form with input fields for various information required to generate a cover letter.
It prompts the user to enter their __Secure-1PSID and __Secure-1PSIDTS tokens, company name, role they are applying for,
contact person, their name, personal experience, job description, and their passion.
The function then returns the entered __Secure-1PSID token, __Secure-1PSIDTS token, a cover letter prompt, and a submit button.
:return: A tuple containing the entered __Secure-1PSID token, __Secure-1PSIDTS token, cover letter prompt, and submit button.
"""
with st.form(key="my_form_to_submit"):
st.markdown(
"## BARD API token\n"
"Go to https://bard.google.com/\n"
"- F12 for console\n"
"- Copy the values of the cookies:\n"
" - Session: Go to Application β Cookies β `__Secure-1PSID` and `__Secure-1PSIDTS`. Copy the value of both cookies respectively."
)
psid = st.text_input(
label="Enter your __Secure-1PSID",
max_chars=100,
type="default",
placeholder="Place yours PSID. It ends with a dot.",
)
psidts = st.text_input(
label="Enter your __Secure-1PSIDTS",
max_chars=100,
type="default",
placeholder="Place yours PSIDTS...",
)
company_name = st.text_input("Company Name: ", "Google")
role = st.text_input(
"What role are you applying for? ", "Machine Learning Engineer"
)
contact_person = st.text_input("Who are you emailing? ", "Hiring Manager")
your_name = st.text_input("What is your name? ", "Hari Bahadur")
personal_exp = st.text_input(
"I have experience in...",
"natural language processing, fraud detection, statistical modeling, and machine learning algorithms. ",
)
job_desc = st.text_input(
"I am excited about the job because...",
"this role will allow me to work on technically challenging problems and create impactful solutions while working with an innovative team. ",
)
passion = st.text_input(
"I am passionate about...",
"solving problems at the intersection of technology and social good.",
)
# make a loading bar using tqdm
submit_button = st.form_submit_button(label="Submit")
prompt = (
"Write a cover letter to "
+ contact_person
+ " from "
+ your_name
+ " for a "
+ role
+ " job at "
+ company_name
+ "."
+ " I have experience in "
+ personal_exp
+ " I am excited about the job because "
+ job_desc
+ " I am passionate about "
+ passion
)
return psid, psidts, prompt, submit_button
psid, psidts, prompt, submit_button = prompt_letter()
if submit_button:
chatbot = Chatbot(psid, psidts)
ans = chatbot.ask(prompt)
st.write("\n _Please read it carefully and make changes as needed._ \n")
st.write(ans["content"])
|