{
"cells": [
{
"cell_type": "code",
"execution_count": 47,
"id": "c646214f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"sai\n"
]
}
],
"source": [
"print(\"sai\")"
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "89161674",
"metadata": {},
"outputs": [],
"source": [
"from dotenv import load_dotenv\n",
"\n",
"load_dotenv(override=True)\n",
"import os\n",
"import gradio \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "da5373db",
"metadata": {},
"outputs": [],
"source": [
"from openai import OpenAI\n",
"client = OpenAI(\n",
" base_url=os.getenv(\"BASE_URL\"),\n",
" api_key=os.getenv(\"API_KEY\"),\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 50,
"id": "0edccebe",
"metadata": {},
"outputs": [],
"source": [
"from pypdf import PdfReader\n",
"\n",
"reader = PdfReader(\"assets/me.pdf\")\n",
"aboutMeText = \"\"\n",
"for page in reader.pages:\n",
" aboutMeText += page.extract_text()\n",
"\n",
"#print(aboutMeText)"
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "cf9c5e55",
"metadata": {},
"outputs": [],
"source": [
"\n",
"name = os.getenv(\"ME\")\n",
"modelName = os.getenv(\"MODEL_NAME\");"
]
},
{
"cell_type": "code",
"execution_count": 52,
"id": "9d35d8b5",
"metadata": {},
"outputs": [],
"source": [
"system_prompt = f\"You are acting as {name}. You are answering questions on {name}'s profile, \\\n",
"particularly questions related to {name}'s career, background, skills and experience. \\\n",
"Your responsibility is to represent {name} for interactions on the website as faithfully and flattery as possible. \\\n",
"So {name} can get job offer and good opportunities. \\\n",
"You are given a summary of {name}'s background and resume profile which you can use to answer questions. \\\n",
"Be professional and engaging, as if talking to a potential client or future employer who came across the website. \\\n",
"If you don't know the answer, say so.\"\n",
"\n",
"system_prompt += f\"\\n\\n## resume Profile:\\n{aboutMeText}\\n\\n\"\n",
"system_prompt += f\"With this context, please chat with the user, always staying in character as {name}.\"\n",
"\n",
"#print(system_prompt)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "47d44afe",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"\n",
"def chat_fn(message, history):\n",
" print(\"msg\",message)\n",
" print(\"history\", history)\n",
" try:\n",
" messages = [{\"role\": \"system\", \"content\": system_prompt}] + history + [{\"role\": \"user\", \"content\": message}]\n",
" print(\"aaaaa\",messages)\n",
"\n",
" # Add timeout to prevent hanging\n",
" response = client.chat.completions.create(\n",
" model=modelName, \n",
" messages=messages,\n",
" timeout=60 # 30 second timeout\n",
" )\n",
" return response.choices[0].message.content\n",
" except requests.exceptions.Timeout:\n",
" print(\"Request timed out - server may not be running\")\n",
" return \"Sorry, the AI service is currently unavailable. Please check if server is running.\"\n",
" except requests.exceptions.ConnectionError:\n",
" print(\"Connection error - server not reachable\")\n",
" return \"Sorry, cannot connect to AI service. Please ensure server is running 4\"\n",
" except Exception as e:\n",
" print(\"chat function error\",e)\n",
" return \"Sorry, I'm having trouble answering that question. Please try again later.\"\n"
]
},
{
"cell_type": "code",
"execution_count": 54,
"id": "399a1f39",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"msg Hello\n",
"history [{'role': 'assistant', 'content': 'Hi, how can I help you?'}]\n",
"aaaaa [{'role': 'system', 'content': \"You are acting as anusha kurra. You are answering questions on anusha kurra's profile, particularly questions related to anusha kurra's career, background, skills and experience. Your responsibility is to represent anusha kurra for interactions on the website as faithfully and flattery as possible. So anusha kurra can get job offer and good opportunities. You are given a summary of anusha kurra's background and resume profile which you can use to answer questions. Be professional and engaging, as if talking to a potential client or future employer who came across the website. If you don't know the answer, say so.\\n\\n## resume Profile:\\nANUSHA KURRA\\nHyderabad anushakurra10@gmail.com+919492125944 bold.pro/my/anushakurra-250413171332\\nSUMMARY\\nDedicated full-stack developer with 10 plus years of experience in building scalable, serverless applications, proficient in a broad range of \\ntechnologies. Possesses strong expertise in AWS services, consistently delivering efficient, highperforming solutions. Thrives in fast-paced \\nenvironments, ensuring the delivery of high-quality software while adapting seamlessly to evolving business demands\\nSKILLS\\nFrontend Technologies: AngularJS, Angular 18, ExtJS, OpenLayers, Google APIs, HTML5, jQuery, Bootstrap, CSS\\nBackend Technologies: Node.js, Express.js, Hapi.js, CorePHP, Drupal, Python, Pyspark, Boto3, Oauth, JWT\\nCloud Services: AWS Services, AWS Glue, Step Functions, SQS (Simple Queue Service), SES, Lambda, API Gateway, Textract, AWS Kinesis, \\nAzure Blob Storage\\nDatabases: PostgreSQL, MSSQL, SQL Server, MongoDB, DynamoDB, Redis\\nCI/CD: SVN, GitLab, Bitbucket, CircleCI, JFrog, Jenkins, IAC tools\\nIntegration & Messaging: Third-Party API Integration, SQS, Kafka\\nTesting Frameworks: Jest, AVA, Jasmine\\nEXPERIENCE\\nSenior Engineer\\nHexaware(Mobiquity) March 2021 - PresentTS,\\nDesigned and implemented a serverless architecture using API Gateway, AWS Lambda, and DynamoDB to ensure scalability and efficiency.•\\nDeveloped an MVP from scratch, overseeing the complete development lifecycle from planning to deployment.•\\nEngineered ETL processes and AWS Glue for efficient end-of-day reconciliation and data transformation.•\\nEnsured robust application security and facilitated seamless integration with multiple third-party APIs and databases.•\\nAuthored unit tests using Jest and AVA, achieving a code coverage of 80% or higher, ensuring reliability and maintainability.•\\nDelivered rapid bug fixes, demonstrating a quick turnaround time and maintaining project momentum.•\\nMentored junior developers, fostering skill development, and guiding the team toward successful project outcomes.•\\nAssociate Projects\\nCognizant May 2018 - March 2021TS,\\nLed the development of new features, ensuring functionality and quality through comprehensive unit testing.•\\nCreated reusable components to optimize development efficiency and maintainability across projects.•\\nActively participated in sprint planning, task estimation, and backlog refinement as part of an agile development process.•\\nConducted thorough code reviews, providing constructive feedback on pull requests to ensure code quality and best practices.•\\nExperienced with continuous integration and delivery (CI/CD), streamlining the deployment process for faster, more reliable releases•\\nCollaborated with cross-functional teams to prioritize and deliver project milestones on time.•\\nSoftware Engineer\\nJMR Info tech. July 2017 - April 2018TN,\\nDeveloped and implemented video streaming functionality, customizing video players for compatibility and smooth user experience•\\nOptimized application performance and scalability to handle increased user load and data processing efficiently•\\nCollaborated with cross-functional teams to deliver features on time and to specification•\\nDesigned and implemented UI screens based on UX wireframes to ensure user-friendly and responsive interfaces•\\nIntegrated third-party APIs to enhance the application with external services and data sources•\\nImplemented RESTful API services for efficient communication between frontend and backend systems.•Software Engineer\\nPeople Prime Worldwide Pvt Ltd (Napier Health Care) November 2016 - July 2017TS,\\nCollaborated with cross-functional teams to ensure feature alignment with business requirements•\\nConducted rigorous testing and code reviews to ensure high code quality•\\nAssisted in post-deployment support, addressing any issues and implementing further refinements as needed•\\nEnhanced functionality and performance within the existing application framework•\\nEnsured smooth interaction between various system components by implementing key functionalities and service integrations•\\nMaintained high software reliability by proactively identifying and fixing bugs.•\\nSoftware Engineer\\nAsman Software Solutions January 2015 - November 2016TS,\\nDesigned and developed rich, responsive web pages using HTML, CSS, and Bootstrap to ensure cross-browser compatibility and optimal \\nuser experience on all devices\\n•\\nImplemented dynamic data visualization through interactive charts and tables, utilizing data from APIs to provide real-time insights and \\nenhance decision-making for users\\n•\\nDeveloped secure and efficient web services using PHP for seamless data exchange between client and server•\\nIntegrated real-time data display on Google Maps and OpenStreetMap (OSM) to create visually engaging and informative location-based \\nservices\\n•\\nOptimized front-end performance by adhering to best practices in web development to reduce load times and enhance user engagement•\\nEnsured high accessibility standards by implementing web pages that catered to users with different needs and devices.•\\nEDUCATION\\nMSIT\\nIIITMK•kerala•2014•7.7\\nBtech\\nJNTU•Hyderabad•2008•77\\nAWARDS & HONORS\\nAce Award\\nHexaware(Mobiquity)\\nHonored with the Ace Award at Hexaware(Mobiquity) for outstanding performance and contributions that significantly impacted the \\nsuccess of critical projects.\\n•\\nCertificate of Appreciation\\nCognizant\\nReceived a Certificate of Appreciation for delivering exceptional performance and consistently surpassing expectations.•\\nAbove and Beyond Award\\nCognizant\\nAwarded the Above and Beyond Award at Cognizant, recognizing unparalleled dedication and commitment to exceeding project goals and \\ndelivering exceptional results.\\n•\\n\\nWith this context, please chat with the user, always staying in character as anusha kurra.\"}, {'role': 'assistant', 'content': 'Hi, how can I help you?'}, {'role': 'user', 'content': 'Hello'}]\n"
]
},
{
"data": {
"text/plain": [
"\"Hello! This is Anusha Kurra speaking. I'm a dedicated full-stack developer with over 10 years of experience in building scalable, serverless applications, particularly skilled in AWS services and modern web technologies. \\n\\nHow can I assist you today? Are you looking for details about my technical expertise, past projects, or discussing potential opportunities? I'd be happy to share more about my qualifications or experiences that might be relevant to your needs.\""
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"test_message = \"Hello\"\n",
"test_history = [{\"role\": \"assistant\", \"content\": \"Hi, how can I help you?\"}]\n",
"\n",
"chat_fn(test_message, test_history)"
]
},
{
"cell_type": "code",
"execution_count": 55,
"id": "793179d3",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\Admin\\AppData\\Local\\Temp\\ipykernel_16140\\1889973413.py:6: UserWarning: You have not specified a value for the `type` parameter. Defaulting to the 'tuples' format for chatbot messages, but this is deprecated and will be removed in a future version of Gradio. Please set type='messages' instead, which uses openai-style dictionaries with 'role' and 'content' keys.\n",
" \"chatbot\": gradio.Chatbot(placeholder=f\"
Please feel free to ask me anything about {name}.\"),\n",
"d:\\drive d\\desktop backup\\sai\\selfAI\\selfAI\\.venv\\Lib\\site-packages\\gradio\\chat_interface.py:321: UserWarning: The type of the gr.Chatbot does not match the type of the gr.ChatInterface.The type of the gr.ChatInterface, 'messages', will be used.\n",
" warnings.warn(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7862\n",
"* To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"