Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,8 +6,8 @@ OPENAI_ENDPOINT = "https://rag-openai-service-ak.openai.azure.com/"
|
|
| 6 |
OPENAI_KEY = "B1XyCaz87o456EVD949oODcGC8KTAEQsNLI7Yq5cnYKk41SMY9PtJQQJ99AKACHYHv6XJ3w3AAABACOGAaCZ"
|
| 7 |
DEPLOYMENT_ID = "gpt-4-rag-ak"
|
| 8 |
|
|
|
|
| 9 |
def call_openai_api(prompt):
|
| 10 |
-
"""Call the Azure OpenAI API with the provided prompt."""
|
| 11 |
url = f"{OPENAI_ENDPOINT}openai/deployments/{DEPLOYMENT_ID}/completions?api-version=2023-05-15"
|
| 12 |
headers = {
|
| 13 |
"Content-Type": "application/json",
|
|
@@ -18,8 +18,8 @@ def call_openai_api(prompt):
|
|
| 18 |
"max_tokens": 500,
|
| 19 |
"temperature": 0.7
|
| 20 |
}
|
| 21 |
-
|
| 22 |
response = requests.post(url, headers=headers, json=data)
|
|
|
|
| 23 |
if response.status_code != 200:
|
| 24 |
return f"Error: {response.status_code} - {response.text}"
|
| 25 |
|
|
@@ -32,16 +32,11 @@ def get_predefined_questions():
|
|
| 32 |
"What is the scope of AI in engineering?",
|
| 33 |
"What are the key highlights of the Master of Engineering Handbook?",
|
| 34 |
"How to start a career in AI?",
|
| 35 |
-
"What is the CPT start date?"
|
| 36 |
-
"What skills are required for a career in AI?",
|
| 37 |
-
"How does the Master of Engineering program support career growth?",
|
| 38 |
-
"What industries use AI extensively?",
|
| 39 |
-
"How can I learn machine learning?",
|
| 40 |
-
"What are the ethical concerns in AI?"
|
| 41 |
]
|
| 42 |
|
|
|
|
| 43 |
def process_query(question):
|
| 44 |
-
"""Process the query and return the response from Azure OpenAI."""
|
| 45 |
return call_openai_api(question)
|
| 46 |
|
| 47 |
# Gradio UI
|
|
@@ -63,4 +58,4 @@ def main():
|
|
| 63 |
demo.launch()
|
| 64 |
|
| 65 |
if __name__ == "__main__":
|
| 66 |
-
main()
|
|
|
|
| 6 |
OPENAI_KEY = "B1XyCaz87o456EVD949oODcGC8KTAEQsNLI7Yq5cnYKk41SMY9PtJQQJ99AKACHYHv6XJ3w3AAABACOGAaCZ"
|
| 7 |
DEPLOYMENT_ID = "gpt-4-rag-ak"
|
| 8 |
|
| 9 |
+
# Function to Call Azure OpenAI API
|
| 10 |
def call_openai_api(prompt):
|
|
|
|
| 11 |
url = f"{OPENAI_ENDPOINT}openai/deployments/{DEPLOYMENT_ID}/completions?api-version=2023-05-15"
|
| 12 |
headers = {
|
| 13 |
"Content-Type": "application/json",
|
|
|
|
| 18 |
"max_tokens": 500,
|
| 19 |
"temperature": 0.7
|
| 20 |
}
|
|
|
|
| 21 |
response = requests.post(url, headers=headers, json=data)
|
| 22 |
+
|
| 23 |
if response.status_code != 200:
|
| 24 |
return f"Error: {response.status_code} - {response.text}"
|
| 25 |
|
|
|
|
| 32 |
"What is the scope of AI in engineering?",
|
| 33 |
"What are the key highlights of the Master of Engineering Handbook?",
|
| 34 |
"How to start a career in AI?",
|
| 35 |
+
"What is the CPT start date?"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
]
|
| 37 |
|
| 38 |
+
# Function to Process Query
|
| 39 |
def process_query(question):
|
|
|
|
| 40 |
return call_openai_api(question)
|
| 41 |
|
| 42 |
# Gradio UI
|
|
|
|
| 58 |
demo.launch()
|
| 59 |
|
| 60 |
if __name__ == "__main__":
|
| 61 |
+
main()
|