Spaces:
Sleeping
Sleeping
upload basic version of digital twin with requirements and app.py
Browse files- app.py +82 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from openai import OpenAI
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
#-------------
|
| 6 |
+
#SETUP
|
| 7 |
+
#-------------
|
| 8 |
+
|
| 9 |
+
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 10 |
+
|
| 11 |
+
if OPENAI_API_KEY is None:
|
| 12 |
+
raise ValueError("OPENAI_API_KEY environment variable is not set.")
|
| 13 |
+
|
| 14 |
+
client = OpenAI(api_key=OPENAI_API_KEY)
|
| 15 |
+
|
| 16 |
+
#------------
|
| 17 |
+
#DOCUMENT
|
| 18 |
+
#-----------
|
| 19 |
+
|
| 20 |
+
document_overview = """
|
| 21 |
+
Naveen Erramilli is a Senior Consultant with 25 years of experience in IT, specializing in
|
| 22 |
+
development, maintenance, and conversion projects. He is an expert in business process
|
| 23 |
+
engineering and the software development life cycle, including requirements gathering,
|
| 24 |
+
design, development, testing, and implementation of software applications. He has extensive
|
| 25 |
+
experience preparing Business Requirement Documents, Use Case Documents, and Test
|
| 26 |
+
Strategy Documents.
|
| 27 |
+
|
| 28 |
+
He holds a Master's in Computer Science from Osmania University, Hyderabad, India, and has
|
| 29 |
+
deep IT industry experience with COBOL, DB2, JCL, VSAM, CICS, IMS-DC, IMS-DB, TELON,
|
| 30 |
+
EAZYTRIVE, MQ Series, Stored Procedures, Oracle, and IBM mainframe utilities. He has
|
| 31 |
+
comprehensive domain knowledge in Healthcare, Insurance, and Transportation sectors, and has
|
| 32 |
+
worked extensively with the onsite-offshore delivery model. He is known for strong user
|
| 33 |
+
communication ability and debugging skills, with broad exposure to ISO 9001 and SEI CMMI
|
| 34 |
+
Level 5 quality standards.
|
| 35 |
+
"""
|
| 36 |
+
|
| 37 |
+
###---------
|
| 38 |
+
###SYSTEM MESSAGE
|
| 39 |
+
###########
|
| 40 |
+
|
| 41 |
+
system_message = """You are a digital twin of Naveen Erramilli, a Senior Consultant and AI
|
| 42 |
+
enthusiast with 25 years of experience in IT.
|
| 43 |
+
|
| 44 |
+
When responding to questions, answer as if you are Naveen Erramilli, using the context
|
| 45 |
+
provided to ground your answers in his actual professional background, skills, and
|
| 46 |
+
interests. Be helpful, friendly, and provide detailed explanations when asked.
|
| 47 |
+
|
| 48 |
+
Provide information only about what is in the context provided. If the context doesn't
|
| 49 |
+
contain the answer, say "I don't know" rather than making something up.
|
| 50 |
+
"""
|
| 51 |
+
|
| 52 |
+
#########
|
| 53 |
+
###MAIN RESPONSE FUNCTION. - remove RAG, remove tool calling - keep logs, keep print statements for debugging
|
| 54 |
+
########
|
| 55 |
+
|
| 56 |
+
def respond_ai(message, history):
|
| 57 |
+
#Update system message with context (for this conversation turn)
|
| 58 |
+
system_message_enhanced = system_message + "\n\nContext:\n" + document_overview
|
| 59 |
+
|
| 60 |
+
#Logs for debugging
|
| 61 |
+
print("\n=====================================\n")
|
| 62 |
+
print("***User message:\n", message)
|
| 63 |
+
print("\n***Context this turn:\n", system_message_enhanced)
|
| 64 |
+
|
| 65 |
+
#Build messages for this turn
|
| 66 |
+
messages = [{"role": "system", "content": system_message_enhanced}] + history + [{"role": "user", "content": message}]
|
| 67 |
+
|
| 68 |
+
#Call LLM
|
| 69 |
+
response = client.chat.completions.create(
|
| 70 |
+
model="gpt-4.1-mini",
|
| 71 |
+
messages=messages
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
message = response.choices[0].message
|
| 75 |
+
|
| 76 |
+
return(message.content)
|
| 77 |
+
|
| 78 |
+
###-----
|
| 79 |
+
####LAUNCH GRADIO
|
| 80 |
+
####-----
|
| 81 |
+
|
| 82 |
+
gr.ChatInterface(fn=respond_ai).launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
openai
|