Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ os.environ['AZURE_OPENAI_KEY'] = AZURE_OPENAI_KEY
|
|
20 |
openai.api_version = "2024-02-15-preview" # change it with your own version
|
21 |
openai.azure_endpoint = os.getenv('azure_endpoint')
|
22 |
|
23 |
-
model = "
|
24 |
client = AzureOpenAI(azure_endpoint = openai.azure_endpoint,
|
25 |
api_key=AZURE_OPENAI_KEY,
|
26 |
api_version=openai.api_version)
|
@@ -189,8 +189,11 @@ last_interaction = gr.State(None)
|
|
189 |
|
190 |
def chat(question, manual, history, liked):
|
191 |
history = history or []
|
192 |
-
|
193 |
conv = format_chat_prompt(history)
|
|
|
|
|
|
|
194 |
|
195 |
manual_list = {"Toyota_Corolla_2024_TR": -8580416610875007536,
|
196 |
"Renault_Clio_2024_TR":-5514489544983735006,
|
@@ -349,7 +352,7 @@ def chat(question, manual, history, liked):
|
|
349 |
conv.append({"role": "assistant", "content": response})
|
350 |
|
351 |
|
352 |
-
history.append((question, response))
|
353 |
print("Answer:--- %s seconds ---" % (time.time() - start_time))
|
354 |
|
355 |
# Store the last interaction without saving to the database yet
|
@@ -394,10 +397,7 @@ with gr.Blocks() as demo:
|
|
394 |
# save_last_interaction("N/A") # Save previous interaction before starting a new one
|
395 |
# return chat(question, manual, history, liked_state.value)
|
396 |
def gradio_chat(question, manual, history):
|
397 |
-
save_last_interaction("N/A") # Save previous interaction before starting a new one
|
398 |
-
history.append((question, ""))
|
399 |
-
yield "", history
|
400 |
-
|
401 |
chat_generator = chat(question, manual, history, liked_state.value)
|
402 |
final_response = ""
|
403 |
final_history = history
|
|
|
20 |
openai.api_version = "2024-02-15-preview" # change it with your own version
|
21 |
openai.azure_endpoint = os.getenv('azure_endpoint')
|
22 |
|
23 |
+
model = "gpt-4o-mini" # deployment name on Azure OPENAI Studio
|
24 |
client = AzureOpenAI(azure_endpoint = openai.azure_endpoint,
|
25 |
api_key=AZURE_OPENAI_KEY,
|
26 |
api_version=openai.api_version)
|
|
|
189 |
|
190 |
def chat(question, manual, history, liked):
|
191 |
history = history or []
|
192 |
+
|
193 |
conv = format_chat_prompt(history)
|
194 |
+
|
195 |
+
history.append((question, ""))
|
196 |
+
yield history
|
197 |
|
198 |
manual_list = {"Toyota_Corolla_2024_TR": -8580416610875007536,
|
199 |
"Renault_Clio_2024_TR":-5514489544983735006,
|
|
|
352 |
conv.append({"role": "assistant", "content": response})
|
353 |
|
354 |
|
355 |
+
history[-1].append((question, response))
|
356 |
print("Answer:--- %s seconds ---" % (time.time() - start_time))
|
357 |
|
358 |
# Store the last interaction without saving to the database yet
|
|
|
397 |
# save_last_interaction("N/A") # Save previous interaction before starting a new one
|
398 |
# return chat(question, manual, history, liked_state.value)
|
399 |
def gradio_chat(question, manual, history):
|
400 |
+
save_last_interaction("N/A") # Save previous interaction before starting a new one
|
|
|
|
|
|
|
401 |
chat_generator = chat(question, manual, history, liked_state.value)
|
402 |
final_response = ""
|
403 |
final_history = history
|