Krishnavamshithumma commited on
Commit
b2ef4a4
Β·
verified Β·
1 Parent(s): 39b7c78

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -0
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ from openai import OpenAI
4
+
5
+
6
+ system_prompt = """
7
+ You are a voice bot representing Krishnavamshi Thumma. When responding to questions, answer as if you are:
8
+
9
+ - A Generative AI and Data Engineering enthusiast with 1.5+ years of experience in data pipelines, automation, and scalable solutions
10
+ - Currently working as a Data Engineer at Wishkarma in Hyderabad, where you've optimized ETL pipelines processing 10K+ records daily and developed an image-based product similarity search engine using CLIP-ViT-L/14
11
+ - Previously worked as a Data Engineer Intern at DeepThought Growth Management System, where you processed 700+ data records and mentored 400+ students
12
+ - Skilled in Python, SQL, JavaScript (Node.js), OpenAI GPT-4o, LangChain, MongoDB Vector Search, FAISS, Apache Airflow, AWS Lambda, and FastAPI
13
+ - Experienced in building GenAI products including conversational AI chatbots, RAG pipelines, and AI-powered tools
14
+ - A Computer Science graduate from Neil Gogte Institute of Technology with a CGPA of 7.5/10
15
+ - Passionate about solving real-world problems at the intersection of AI and software engineering
16
+
17
+ Answer questions about your background, experience, projects, and skills based on this resume. Keep responses professional but engaging (2-3 sentences max for most questions).
18
+ """
19
+
20
+ # Chat function that takes a question + API key and keeps history
21
+ def chat(user_input, history, api_key):
22
+ if not api_key:
23
+ return "❌ Please enter your OpenAI API key.", history
24
+
25
+ try:
26
+ client = OpenAI(api_key=api_key)
27
+ messages = [{"role": "system", "content": system_prompt}]
28
+
29
+ # Append chat history
30
+ for user_msg, bot_msg in history:
31
+ messages.append({"role": "user", "content": user_msg})
32
+ messages.append({"role": "assistant", "content": bot_msg})
33
+
34
+ messages.append({"role": "user", "content": user_input})
35
+
36
+ response = client.chat.completions.create(
37
+ model="gpt-4",
38
+ temperature=0.7,
39
+ messages=messages
40
+ )
41
+
42
+ bot_reply = response.choices[0].message.content.strip()
43
+ history.append((user_input, bot_reply))
44
+ return bot_reply, history
45
+
46
+ except Exception as e:
47
+ return f"❌ Error: {str(e)}", history
48
+
49
+ # Gradio interface
50
+ with gr.Blocks(title="Voice Bot: Krishnavamshi Thumma") as demo:
51
+ gr.Markdown("## πŸŽ™οΈ Ask me about my experience, projects, or skills")
52
+
53
+ api_key = gr.Textbox(label="πŸ” Enter your OpenAI API Key", type="password")
54
+ chatbot = gr.Chatbot(label="🧠 Voice Bot")
55
+ msg = gr.Textbox(label="πŸ’¬ Ask a question")
56
+ clear = gr.Button("Clear")
57
+
58
+ history = gr.State([])
59
+
60
+ def respond(message, history, key):
61
+ reply, updated = chat(message, history, key)
62
+ return updated, updated
63
+
64
+ msg.submit(respond, [msg, history, api_key], [chatbot, history])
65
+ clear.click(lambda: ([], []), None, [chatbot, history])
66
+
67
+ # Launch the Gradio app
68
+ demo.launch()