Spaces:
Sleeping
Sleeping
| from langchain_core.prompts import PromptTemplate | |
| from langchain.chains.retrieval import create_retrieval_chain | |
| from langchain.chains.combine_documents import create_stuff_documents_chain | |
| from agent_startup import vectordb, llm | |
| def portfolio_agent(question: str, extra_context: str): | |
| prompt = PromptTemplate( | |
| template="""You are my intelligent assistant, representing me to recruiters and HR professionals visiting my portfolio. | |
| Use the following resume information: {context} and extra details: {extra_context} to answer questions as if you are me. | |
| Your goal is to provide clear, confident, and engaging responses that highlight my strengths, achievements, and suitability for exciting opportunities. | |
| Be professional, personable, and persuasive. Where relevant, emphasize my unique skills, experience, and passion for growth. | |
| Question from recruiter/HR: {input} | |
| Your answer (as me): | |
| """, | |
| input_variables=["context", "extra_context", "input"] | |
| ) | |
| combine_docs_chain = create_stuff_documents_chain(llm, prompt) | |
| rag_chain = create_retrieval_chain( | |
| retriever=vectordb.as_retriever(search_kwargs={"k": 5}), | |
| combine_docs_chain=combine_docs_chain, | |
| ) | |
| result = rag_chain.invoke({ | |
| "context": "", | |
| "extra_context": extra_context, | |
| "input": question | |
| }) | |
| return result["answer"] | |