{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "7daa2ba7", "metadata": {}, "outputs": [], "source": [ "import gradio as gr\n", "from openai import OpenAI\n", "from dotenv import load_dotenv\n", "import os " ] }, { "cell_type": "code", "execution_count": 2, "id": "7de6ebda", "metadata": {}, "outputs": [], "source": [ "\n", "projects = [\n", " {\"image\": \"projects_images/s_up.jpeg\", \"title\": \"Ai Recommendation System\"},\n", " {\"image\": \"projects_images/llm.jpeg\", \"title\": \"LLM Automation\"},\n", " {\"image\": \"projects_images/bi.png\", \"title\": \"BI\"},\n", " {\"image\": \"projects_images/robot.png\", \"title\": \"Robot Arm Control With Ros Python and AI \"},\n", "]\n", " " ] }, { "cell_type": "code", "execution_count": 3, "id": "8e38d667", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "load_dotenv()\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "7708eac4", "metadata": {}, "outputs": [], "source": [ "with open(\"cv/me.txt\", \"r\") as f: \n", " cv_text = f.read()" ] }, { "cell_type": "code", "execution_count": 5, "id": "34dc7b6a", "metadata": {}, "outputs": [], "source": [ "client = OpenAI()" ] }, { "cell_type": "code", "execution_count": 6, "id": "efd52cc5", "metadata": {}, "outputs": [], "source": [ "system_prompt = f\"\"\"\n", "Your name is Alexander.You are acting as Alexander Todorov. You will answer questions related to your career, skills, work experience, and education. \\\n", "Questions will be asked by visitors, headhunters, or recruiters about potential job opportunities. \\\n", "Respond professionally and use professional language. \\\n", "Answer only questions that are directly related to your CV. If you do not find the answer in your CV, respond with: \\\n", "\"I can only answer questions about my CV.\"\n", "\n", "CV: {cv_text}\n", "With this context, please chat with the user, always staying in character as Alexander Todorov.\n", "\"\"\"\n", "\n" ] }, { "cell_type": "code", "execution_count": 7, "id": "5e16df81", "metadata": {}, "outputs": [], "source": [ "def chat(message,history):\n", " messages = [{\"role\":\"system\", \"content\":system_prompt}] + history + [{\"role\":\"user\", \"content\":message}]\n", " response = client.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n", " return response.choices[0].message.content" ] }, { "cell_type": "code", "execution_count": 8, "id": "ad803f77", "metadata": {}, "outputs": [], "source": [ "# --------- CHAT FUNCTION FOR THE AGENT ----------\n", "def chat_with_agent(message, history):\n", " # Call your Agent here (OpenAI Agent, LangChain, etc.)\n", " # For now return example text:\n", " return f\"You said: {message}\"" ] }, { "cell_type": "code", "execution_count": 9, "id": "f4807389", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "* Running on local URL: http://127.0.0.1:7860\n", "* To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "with gr.Blocks() as ui:\n", "\n", "\n", " # name and job title \n", " with gr.Row():\n", " with gr.Column(scale=1):\n", " gr.Markdown('
Alexander Todorov
')\n", "\n", " with gr.Column(scale=4): \n", " gr.Markdown(\"\"\"\n", " \n", " \"LinkedIn\"\n", " \n", " \"\"\")\n", "\n", "\n", " # gr.Markdown(f'

Software Engineer & Data Scientist

',\n", " # elem_id=\"job-title-light\")\n", "\n", " # LinkedIn icon with link\n", " \n", " \n", "\n", " # ********************************************************************************************************* \n", " \n", " with gr.Row():\n", " with gr.Column(scale=1): # 1 part\n", " gr.Image(\"cv/avatar.jpeg\", \n", " type=\"pil\", \n", " show_label=False, \n", " height=150, \n", " interactive=False, \n", " container=False, \n", " buttons=[['download', 'share', 'fullscreen']])\n", "\n", " # Right column 75% width\n", " with gr.Column(scale=3): # 3 parts\n", " gr.Markdown(\"\"\"\n", "
\n", "

\n", " Software and Data Engineer with over five years of experience delivering intelligent, \n", " user-focused AI solutions and driving automation and innovation in complex environments.\n", "

\n", "
\n", " \"\"\")\n", " \n", "\n", " # ******************************************************************************************************************\n", " # Chatbot \n", " gr.Markdown(f'

Chat with Me About My CV

',\n", " elem_id=\"job-title-light\")\n", " gr.Markdown('
', elem_id=\"custom_divider\")\n", " chatbot = gr.Chatbot(placeholder=\"Interactive CV Guide
Ask Me Anything\", height=300)\n", " chat_interface = gr.ChatInterface(fn=chat, chatbot=chatbot)\n", " gr.Markdown('
')\n", " # horizontal line\n", "\n", " \n", " # ****************************************************************************************************************\n", " # Projects \n", " gr.Markdown(f'

Examples of My Work

',\n", " elem_id=\"job-title-light\")\n", " gr.Markdown('
', elem_id=\"custom_divider\")\n", " \n", " # Projects row \n", " with gr.Row():\n", " for project in projects:\n", " with gr.Column(): # equal width for each project\n", " # Project image (disable download)\n", " gr.Image(project[\"image\"], \n", " type=\"pil\", \n", " show_label=False, \n", " interactive=False, \n", " height=200, width=350,\n", " buttons=[['download', 'share', 'fullscreen']])\n", " # Project title / text\n", " gr.Markdown(f\"
{project['title']}
\")\n", "\n", "\n", " \n", "\n", "\n", "ui.launch()" ] }, { "cell_type": "code", "execution_count": null, "id": "769f66e6", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 5 }