Spaces:
Sleeping
Sleeping
Update app.py
Browse filesmodified hard coding api values to take from environment
app.py
CHANGED
|
@@ -26,13 +26,14 @@ from pathlib import Path
|
|
| 26 |
#====================================SETUP=====================================#
|
| 27 |
# Fetch secrets from Hugging Face Spaces
|
| 28 |
|
| 29 |
-
model_name = "gpt-4o"
|
| 30 |
|
| 31 |
# Extract the OpenAI key and endpoint from the configuration
|
| 32 |
openai_key = os.environ["AZURE_OPENAI_KEY"]
|
| 33 |
azure_endpoint = os.environ["AZURE_OPENAI_ENDPOINT"]
|
| 34 |
api_version = os.environ["AZURE_OPENAI_APIVERSION"]
|
| 35 |
|
|
|
|
| 36 |
|
| 37 |
# Define the location of the SQLite database
|
| 38 |
db_loc = 'ecomm.db'
|
|
@@ -205,6 +206,7 @@ client = AzureOpenAI(
|
|
| 205 |
api_version=os.environ["AZURE_OPENAI_APIVERSION"]
|
| 206 |
)
|
| 207 |
|
|
|
|
| 208 |
|
| 209 |
@tool
|
| 210 |
def rag(user_input: str) -> str:
|
|
@@ -232,7 +234,7 @@ def rag(user_input: str) -> str:
|
|
| 232 |
]
|
| 233 |
try:
|
| 234 |
response = client.chat.completions.create(
|
| 235 |
-
model=
|
| 236 |
messages=prompt
|
| 237 |
)
|
| 238 |
|
|
@@ -549,4 +551,4 @@ def main():
|
|
| 549 |
login_page()
|
| 550 |
|
| 551 |
if __name__ == "__main__":
|
| 552 |
-
main()
|
|
|
|
| 26 |
#====================================SETUP=====================================#
|
| 27 |
# Fetch secrets from Hugging Face Spaces
|
| 28 |
|
| 29 |
+
#model_name = "gpt-4o"
|
| 30 |
|
| 31 |
# Extract the OpenAI key and endpoint from the configuration
|
| 32 |
openai_key = os.environ["AZURE_OPENAI_KEY"]
|
| 33 |
azure_endpoint = os.environ["AZURE_OPENAI_ENDPOINT"]
|
| 34 |
api_version = os.environ["AZURE_OPENAI_APIVERSION"]
|
| 35 |
|
| 36 |
+
model_name = os.environ["CHATGPT_MODEL"]
|
| 37 |
|
| 38 |
# Define the location of the SQLite database
|
| 39 |
db_loc = 'ecomm.db'
|
|
|
|
| 206 |
api_version=os.environ["AZURE_OPENAI_APIVERSION"]
|
| 207 |
)
|
| 208 |
|
| 209 |
+
model_name = os.environ["CHATGPT_MODEL"]
|
| 210 |
|
| 211 |
@tool
|
| 212 |
def rag(user_input: str) -> str:
|
|
|
|
| 234 |
]
|
| 235 |
try:
|
| 236 |
response = client.chat.completions.create(
|
| 237 |
+
model=model_name,
|
| 238 |
messages=prompt
|
| 239 |
)
|
| 240 |
|
|
|
|
| 551 |
login_page()
|
| 552 |
|
| 553 |
if __name__ == "__main__":
|
| 554 |
+
main()
|