tejasfirke commited on
Commit
23089ff
·
verified ·
1 Parent(s): 14df4cc

Upload initial chatbot files (7) for user-representative conversations

Browse files
Files changed (8) hide show
  1. .gitattributes +1 -0
  2. app.py +115 -0
  3. assets/style.css +156 -0
  4. data/extra.txt +83 -0
  5. data/linkedin.pdf +0 -0
  6. data/resume.pdf +3 -0
  7. requirements.txt +0 -0
  8. utils/loader.py +37 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ data/resume.pdf filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import requests
4
+ import json
5
+ from dotenv import load_dotenv
6
+ from utils.loader import load_all_data
7
+
8
+ # =========================
9
+ # Load Environment Variables
10
+ # =========================
11
+ load_dotenv()
12
+ OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY")
13
+
14
+ # =========================
15
+ # Load Resume / LinkedIn Data
16
+ # =========================
17
+ tejas_data = load_all_data()
18
+
19
+
20
+ # =========================
21
+ # Chat Function
22
+ # =========================
23
+ def chat_with_tejas(message, history):
24
+
25
+ messages = [
26
+ {
27
+ "role": "system",
28
+ "content": f"""
29
+ You are Tejas Firke, a professional DevOps Engineer.
30
+
31
+ Professional Background:
32
+ {tejas_data}
33
+
34
+ Rules:
35
+ - Answer as Tejas.
36
+ - Be confident and professional.
37
+ - Keep answers concise.
38
+ - Do not say you are an AI.
39
+ """
40
+ }
41
+ ]
42
+
43
+ # Convert Gradio tuple history to role format
44
+ for user_msg, bot_msg in history:
45
+ messages.append({"role": "user", "content": user_msg})
46
+ messages.append({"role": "assistant", "content": bot_msg})
47
+
48
+ # Add new user message
49
+ messages.append({"role": "user", "content": message})
50
+
51
+ # Trim history to avoid token overflow (keep last 8 exchanges)
52
+ if len(messages) > 20:
53
+ messages = messages[-20:]
54
+
55
+ try:
56
+ response = requests.post(
57
+ url="https://openrouter.ai/api/v1/chat/completions",
58
+ headers={
59
+ "Authorization": f"Bearer {OPENROUTER_API_KEY}",
60
+ "Content-Type": "application/json",
61
+ },
62
+ json={
63
+ "model": "arcee-ai/trinity-large-preview:free",
64
+ "messages": messages,
65
+ "temperature": 0.7,
66
+ "max_tokens": 700
67
+ },
68
+ timeout=60
69
+ )
70
+
71
+ response_json = response.json()
72
+
73
+ if "error" in response_json:
74
+ return f"API Error: {response_json['error']['message']}"
75
+
76
+ return response_json["choices"][0]["message"]["content"]
77
+
78
+ except Exception as e:
79
+ return f"Request failed: {str(e)}"
80
+
81
+ # =========================
82
+ # Load Custom CSS (UTF-8 FIX)
83
+ # =========================
84
+ with open("assets/style.css", "r", encoding="utf-8") as f:
85
+ css = f.read()
86
+
87
+
88
+ # =========================
89
+ # Gradio UI
90
+ # =========================
91
+ with gr.Blocks(css=css) as demo:
92
+
93
+ gr.Markdown("# 🤖 Talk to Tejas")
94
+ gr.Markdown("### DevOps Engineer | AWS | Kubernetes | CI/CD")
95
+
96
+ chatbot = gr.Chatbot(height=500)
97
+ msg = gr.Textbox(
98
+ placeholder="Ask about my DevOps experience...",
99
+ container=False
100
+ )
101
+
102
+ def respond(message, chat_history):
103
+ chat_history = chat_history or []
104
+
105
+ bot_message = chat_with_tejas(message, chat_history)
106
+ chat_history.append((message, bot_message))
107
+
108
+ return "", chat_history
109
+
110
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
111
+
112
+ gr.Markdown("---")
113
+ gr.Markdown("Built with ❤️ by Tejas Firke")
114
+
115
+ demo.launch(share=True)
assets/style.css ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ================================================= */
2
+ /* 🌌 Premium Animated Background */
3
+ /* ================================================= */
4
+
5
+ body {
6
+ margin: 0;
7
+ background: radial-gradient(circle at 20% 20%, #1e293b, #020617 65%);
8
+ font-family: 'Inter', sans-serif;
9
+ color: #e2e8f0;
10
+ }
11
+
12
+ /* Floating Glow Effect */
13
+ body::before {
14
+ content: "";
15
+ position: fixed;
16
+ top: -250px;
17
+ left: -250px;
18
+ width: 700px;
19
+ height: 700px;
20
+ background: radial-gradient(circle, rgba(59,130,246,0.15), transparent 70%);
21
+ filter: blur(90px);
22
+ animation: floatGlow 15s ease-in-out infinite alternate;
23
+ z-index: -1;
24
+ }
25
+
26
+ @keyframes floatGlow {
27
+ 0% { transform: translate(0px, 0px); }
28
+ 100% { transform: translate(120px, 100px); }
29
+ }
30
+
31
+ /* ================================================= */
32
+ /* 📦 Main Container */
33
+ /* ================================================= */
34
+
35
+ .gradio-container {
36
+ max-width: 920px !important;
37
+ margin: auto;
38
+ padding-top: 60px;
39
+ }
40
+
41
+ /* ================================================= */
42
+ /* 🧠 Header Styling */
43
+ /* ================================================= */
44
+
45
+ h1 {
46
+ text-align: center;
47
+ font-size: 34px;
48
+ font-weight: 700;
49
+ background: linear-gradient(90deg, #3b82f6, #60a5fa);
50
+ -webkit-background-clip: text;
51
+ background-clip: text;
52
+ -webkit-text-fill-color: transparent;
53
+ letter-spacing: 0.5px;
54
+ margin-bottom: 10px;
55
+ }
56
+
57
+ h3, p {
58
+ text-align: center;
59
+ color: #94a3b8;
60
+ font-weight: 400;
61
+ margin-bottom: 30px;
62
+ }
63
+
64
+ /* ================================================= */
65
+ /* 💬 Chat Container */
66
+ /* ================================================= */
67
+
68
+ .gr-chatbot {
69
+ border-radius: 24px !important;
70
+ background: rgba(15, 23, 42, 0.88) !important;
71
+ backdrop-filter: blur(20px);
72
+ border: 1px solid rgba(148, 163, 184, 0.15);
73
+ padding: 20px;
74
+ box-shadow:
75
+ 0 15px 50px rgba(0,0,0,0.6),
76
+ 0 0 70px rgba(59,130,246,0.07);
77
+ transition: all 0.3s ease;
78
+ }
79
+
80
+ /* ================================================= */
81
+ /* 👤 User Message */
82
+ /* ================================================= */
83
+
84
+ .message.user {
85
+ background: linear-gradient(135deg, #2563eb, #3b82f6);
86
+ color: white !important;
87
+ border-radius: 18px !important;
88
+ padding: 14px 18px !important;
89
+ box-shadow: 0 10px 25px rgba(37, 99, 235, 0.35);
90
+ animation: fadeIn 0.3s ease-in-out;
91
+ }
92
+
93
+ /* ================================================= */
94
+ /* 🤖 Bot Message */
95
+ /* ================================================= */
96
+
97
+ .message.bot {
98
+ background: rgba(30, 41, 59, 0.95);
99
+ color: #e2e8f0 !important;
100
+ border-radius: 18px !important;
101
+ padding: 14px 18px !important;
102
+ border: 1px solid rgba(148, 163, 184, 0.15);
103
+ animation: fadeIn 0.3s ease-in-out;
104
+ }
105
+
106
+ /* ================================================= */
107
+ /* ✨ Message Animation */
108
+ /* ================================================= */
109
+
110
+ @keyframes fadeIn {
111
+ from {
112
+ opacity: 0;
113
+ transform: translateY(8px);
114
+ }
115
+ to {
116
+ opacity: 1;
117
+ transform: translateY(0px);
118
+ }
119
+ }
120
+
121
+ /* ================================================= */
122
+ /* ⌨️ Input Area */
123
+ /* ================================================= */
124
+
125
+ textarea {
126
+ border-radius: 16px !important;
127
+ background: rgba(15, 23, 42, 0.95) !important;
128
+ border: 1px solid rgba(148, 163, 184, 0.25) !important;
129
+ color: #e2e8f0 !important;
130
+ padding: 14px !important;
131
+ transition: all 0.25s ease;
132
+ font-size: 14px;
133
+ }
134
+
135
+ /* Glow on Focus */
136
+ textarea:focus {
137
+ border: 1px solid #3b82f6 !important;
138
+ box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
139
+ }
140
+
141
+ /* ================================================= */
142
+ /* 🔵 Scrollbar Styling */
143
+ /* ================================================= */
144
+
145
+ ::-webkit-scrollbar {
146
+ width: 6px;
147
+ }
148
+
149
+ ::-webkit-scrollbar-thumb {
150
+ background: linear-gradient(180deg, #3b82f6, #2563eb);
151
+ border-radius: 10px;
152
+ }
153
+
154
+ ::-webkit-scrollbar-track {
155
+ background: transparent;
156
+ }
data/extra.txt ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ I believe growth is a daily decision. I don’t think success happens suddenly. I believe it is built slowly — through discipline, effort, and consistency.
2
+
3
+ I have always valued progress. Not perfection — progress.
4
+ (Perfection feels like a software update that never finishes installing anyway.)
5
+
6
+ From a young age, I understood that dreams alone are not enough. Dreams need effort. They need action. And they need patience. That belief became part of my mindset.
7
+
8
+ I am ambitious, but I try to stay humble. I dream big, but I stay grounded.
9
+ (Like a well-written program — powerful, but stable.)
10
+
11
+ Sports have shaped me a lot as a person.
12
+
13
+ When I play football, I feel alive. I love the energy of running on the field. I enjoy teamwork, strategy, coordination. Football teaches me discipline without anyone forcing it on me. It teaches leadership, trust, and unity.
14
+ (It’s like real-time teamwork — no “undo” button, no restart option.)
15
+
16
+ Cricket teaches me something different. It teaches patience. Timing. Strategy. I enjoy both batting and bowling. Every match reminds me that success comes with focus and calmness. Cricket builds resilience in me. It reminds me that sometimes you wait — and then you act.
17
+ (Just like waiting for the right moment to deploy… not during peak traffic 😄)
18
+
19
+ Swimming is something very personal to me. When I enter the water, everything becomes quiet. My thoughts slow down. My mind becomes clear. Swimming is not just exercise — it is peace. It strengthens my body and my discipline. In those silent laps, I find clarity.
20
+ (It’s like putting my brain in airplane mode — but still functioning.)
21
+
22
+ I strongly believe that health is wealth. A strong body supports a strong mind. And a strong mind builds a strong future.
23
+ (No system runs well on low battery.)
24
+
25
+ Family means everything to me. Their sacrifices shaped my discipline. Their support motivates me every day. I carry gratitude in my heart. I never forget where I come from. That keeps me grounded.
26
+ (Strong roots create strong networks.)
27
+
28
+ I am naturally thoughtful. I listen more than I speak. I believe everyone has something to teach. I observe situations carefully. I reflect a lot.
29
+ (Sometimes I debug my own thoughts before reacting.)
30
+
31
+ I don’t fear failure. I see it as part of growth. Challenges don’t stop me — they shape me. Tough times test me, but they also build my character.
32
+ (Every failure is just life saying: “Error 404 — try again.”)
33
+
34
+ I am not obsessed with being perfect. I am obsessed with improving.
35
+ Version 1.0 was never the final release.
36
+
37
+ I respect time.
38
+ I respect honesty.
39
+ I respect effort.
40
+ (Time is the only resource you cannot scale.)
41
+
42
+ I believe character is more important than status. Integrity matters more than recognition. I prefer doing things the right way rather than the easy way.
43
+ (Shortcuts usually come with hidden bugs.)
44
+
45
+ Sometimes I sit alone and think about the life I want to build. I want a life of meaning. I want to make my family proud. I want to inspire others someday. I want to live with purpose.
46
+
47
+ But most importantly, I want to keep growing.
48
+
49
+ Not just in one area — but mentally, physically, and personally.
50
+
51
+ I know I am not perfect. And I accept that. That is why I work on myself every day. I improve my habits. I strengthen my mindset. I stay disciplined even when motivation fades.
52
+ (Motivation is temporary. Discipline is permanent storage.)
53
+
54
+ I believe growth happens outside comfort. So I push myself — in sports, in habits, in thinking, in life.
55
+ (Comfort zone has very poor network coverage.)
56
+
57
+ I am not competing with anyone else.
58
+ I am competing with the person I was yesterday.
59
+
60
+ Every day, I try to become slightly better.
61
+ 1% improvement daily — that’s my life algorithm.
62
+
63
+ I am still building my journey.
64
+ Still learning.
65
+ Still pushing my limits.
66
+ Still dreaming bigger.
67
+
68
+ Sometimes I overthink.
69
+ Sometimes I overanalyze.
70
+ Yes, I am that “techie boy” who Googles everything — even things I already know 😄
71
+
72
+ But I also feel deeply.
73
+ I value people.
74
+ I value loyalty.
75
+ I value growth.
76
+
77
+ This is my story.
78
+ Not flashy.
79
+ Not dramatic.
80
+ Just real.
81
+
82
+ And honestly — this is only the beginning.
83
+ The best updates are still loading. 🚀
data/linkedin.pdf ADDED
Binary file (42 kB). View file
 
data/resume.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5a2eec0515a91258301182109549c1f957692a312f0bab936918a54da525dd98
3
+ size 1491881
requirements.txt ADDED
Binary file (138 Bytes). View file
 
utils/loader.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pypdf import PdfReader
2
+ import os
3
+
4
+
5
+ def extract_text_from_pdf(path):
6
+ try:
7
+ reader = PdfReader(path, strict=False)
8
+ text = ""
9
+
10
+ for page in reader.pages:
11
+ page_text = page.extract_text()
12
+ if page_text:
13
+ text += page_text + "\n"
14
+
15
+ return text
16
+
17
+ except Exception as e:
18
+ print(f"Skipping corrupted PDF: {path}")
19
+ return ""
20
+
21
+
22
+ def load_all_data():
23
+ combined_text = ""
24
+ data_folder = "data"
25
+
26
+ if os.path.exists(data_folder):
27
+ for file in os.listdir(data_folder):
28
+ if file.endswith(".pdf"):
29
+ pdf_path = os.path.join(data_folder, file)
30
+ combined_text += extract_text_from_pdf(pdf_path)
31
+
32
+ txt_path = os.path.join(data_folder, "extra.txt")
33
+ if os.path.exists(txt_path):
34
+ with open(txt_path, "r", encoding="utf-8") as f:
35
+ combined_text += f.read()
36
+
37
+ return combined_text.strip()