Akash9281 commited on
Commit
eb1e9f9
·
verified ·
1 Parent(s): 7079496

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -3,7 +3,7 @@ import requests
3
 
4
  # Azure OpenAI Configuration
5
  OPENAI_ENDPOINT = "https://rag-openai-service-ak.openai.azure.com/"
6
- OPENAI_KEY = "B1XyCaz87o456EVD949oODcGC8KTAEQsNLI7Yq5cnYKk41SMY9PtJQQJ99AKACHYHv6XJ3w3AAABACOGAaCZ"
7
  DEPLOYMENT_ID = "gpt-4-rag-ak"
8
 
9
  # Function to Call Azure OpenAI API
@@ -25,7 +25,7 @@ def call_openai_api(prompt):
25
 
26
  return response.json()["choices"][0]["text"].strip()
27
 
28
- # Predefined Questions and Sources
29
  def get_predefined_questions():
30
  return [
31
  "What are the career opportunities in AI?",
@@ -44,21 +44,20 @@ def process_query(question):
44
  predefined_responses = {
45
  "What are the career opportunities in AI?": ("AI offers diverse opportunities in data science, machine learning engineering, robotics, and more.", "eBook-How-to-Build-a-Career-in-AI.pdf"),
46
  "What is the scope of AI in engineering?": ("AI in engineering includes predictive maintenance, process optimization, and smart systems.", "eBook-How-to-Build-a-Career-in-AI.pdf"),
47
- "What are the key highlights of the Master of Engineering Handbook?": ("The handbook highlights program structure, course requirements, and career support for MEng students.", "Master of Engineering (MEng) Handbook 2023.pdf"),
48
  "How to start a career in AI?": ("Starting a career in AI involves learning programming, data science, and machine learning frameworks.", "eBook-How-to-Build-a-Career-in-AI.pdf"),
49
- "When will the CPT start date?": ("CPT start date at University Of Cincinnati is May 5 2025. Reach out to Amanda: https://researchdirectory.uc.edu/p/mclaugae", "Master of Engineering (MEng) Handbook 2023.pdf"),
50
  "What are the ethical considerations in AI development?": ("Ethical AI involves fairness, transparency, accountability, and avoiding biases in decision-making systems.", "eBook-How-to-Build-a-Career-in-AI.pdf"),
51
  "What are the differences between supervised and unsupervised learning?": ("Supervised learning uses labeled data for training, while unsupervised learning identifies patterns in unlabeled data.", "eBook-How-to-Build-a-Career-in-AI.pdf"),
52
- "What are the benefits of enrolling in an MEng program?": ("An MEng program provides advanced technical skills, networking opportunities, and industry-oriented training.", "Master of Engineering (MEng) Handbook 2023.pdf"),
53
  "What is the importance of Generative AI in modern technology?": ("Generative AI drives innovation in content creation, design, and personalized user experiences across industries.", "eBook-How-to-Build-a-Career-in-AI.pdf"),
54
- "What is the process to apply for internships as an MEng student?": ("Start with updating your resume, networking, and applying through university portals or job boards like LinkedIn. Reach out to Julie: https://researchdirectory.uc.edu/p/steimlje for more doubts.", "Master of Engineering (MEng) Handbook 2023.pdf")
55
  }
56
 
57
  if question in predefined_responses:
58
  response, source = predefined_responses[question]
59
- return f"Response: {response}\n\nSource: {source}"
60
 
61
- # Use Azure OpenAI for unlisted questions
62
  return call_openai_api(question)
63
 
64
  # Gradio UI
@@ -73,12 +72,7 @@ def main():
73
  fn=chatbot_ui,
74
  inputs=gr.Dropdown(choices=predefined_questions, label="Select a predefined question"),
75
  outputs=gr.Textbox(label="Chatbot Response"),
76
- title="Azure-Powered RAG Chatbot",
77
- live=True,
78
- theme="default",
79
- examples=predefined_questions,
80
- allow_flagging="never",
81
- layout="vertical"
82
  )
83
 
84
  demo.launch()
 
3
 
4
  # Azure OpenAI Configuration
5
  OPENAI_ENDPOINT = "https://rag-openai-service-ak.openai.azure.com/"
6
+ OPENAI_KEY = "B1XyCaz87o456EVD949oODcGC8KTAEQsNLI7Yq5cnYKk41SMY9PtJQQJ99AKACHYHv6XJ3w3AAABACOGHD3K"
7
  DEPLOYMENT_ID = "gpt-4-rag-ak"
8
 
9
  # Function to Call Azure OpenAI API
 
25
 
26
  return response.json()["choices"][0]["text"].strip()
27
 
28
+ # Predefined Questions and Responses with Sources
29
  def get_predefined_questions():
30
  return [
31
  "What are the career opportunities in AI?",
 
44
  predefined_responses = {
45
  "What are the career opportunities in AI?": ("AI offers diverse opportunities in data science, machine learning engineering, robotics, and more.", "eBook-How-to-Build-a-Career-in-AI.pdf"),
46
  "What is the scope of AI in engineering?": ("AI in engineering includes predictive maintenance, process optimization, and smart systems.", "eBook-How-to-Build-a-Career-in-AI.pdf"),
47
+ "What are the key highlights of the Master of Engineering Handbook?": ("The handbook highlights program structure, course requirements, and career support for MEng students.", "Master of Engineering (MEng) Handbook.pdf"),
48
  "How to start a career in AI?": ("Starting a career in AI involves learning programming, data science, and machine learning frameworks.", "eBook-How-to-Build-a-Career-in-AI.pdf"),
49
+ "When will the CPT start date?": ("CPT start date at University Of Cincinnati is May 5, 2025. Reach out to Amanda (https://researchdirectory.uc.edu/p/mclaugae).", "Master of Engineering (MEng) Handbook.pdf"),
50
  "What are the ethical considerations in AI development?": ("Ethical AI involves fairness, transparency, accountability, and avoiding biases in decision-making systems.", "eBook-How-to-Build-a-Career-in-AI.pdf"),
51
  "What are the differences between supervised and unsupervised learning?": ("Supervised learning uses labeled data for training, while unsupervised learning identifies patterns in unlabeled data.", "eBook-How-to-Build-a-Career-in-AI.pdf"),
52
+ "What are the benefits of enrolling in an MEng program?": ("An MEng program provides advanced technical skills, networking opportunities, and industry-oriented training.", "Master of Engineering (MEng) Handbook.pdf"),
53
  "What is the importance of Generative AI in modern technology?": ("Generative AI drives innovation in content creation, design, and personalized user experiences across industries.", "eBook-How-to-Build-a-Career-in-AI.pdf"),
54
+ "What is the process to apply for internships as an MEng student?": ("Start with updating your resume, networking, and applying through university portals or job boards like LinkedIn. Reach out to Julie (https://researchdirectory.uc.edu/p/steimlje) for more doubts.", "Master of Engineering (MEng) Handbook.pdf")
55
  }
56
 
57
  if question in predefined_responses:
58
  response, source = predefined_responses[question]
59
+ return f"{response}\n\nSource: {source}"
60
 
 
61
  return call_openai_api(question)
62
 
63
  # Gradio UI
 
72
  fn=chatbot_ui,
73
  inputs=gr.Dropdown(choices=predefined_questions, label="Select a predefined question"),
74
  outputs=gr.Textbox(label="Chatbot Response"),
75
+ title="Azure-Powered RAG Chatbot"
 
 
 
 
 
76
  )
77
 
78
  demo.launch()