Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
from fastapi import FastAPI
|
|
|
4 |
from routes import query_handler, purchase, order_management, account_management, customer_support, search_products
|
5 |
|
6 |
app = FastAPI()
|
@@ -17,6 +18,8 @@ app.include_router(search_products.router,
|
|
17 |
app.include_router(query_handler.router,
|
18 |
prefix="/query-handler", tags=["query-handler"])
|
19 |
|
|
|
|
|
20 |
|
21 |
def fastlane_agent(message, history):
|
22 |
|
@@ -28,8 +31,7 @@ def fastlane_agent(message, history):
|
|
28 |
{"role": "assistant", "content": assistant})
|
29 |
history_openai_format.append({"role": "user", "content": message})
|
30 |
|
31 |
-
response =
|
32 |
-
"http://localhost:8000/query-handler/", json={"text": message, "history": history_openai_format})
|
33 |
if response.status_code == 200:
|
34 |
return response.json().get("generative response")
|
35 |
else:
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
from fastapi import FastAPI
|
4 |
+
from fastapi.testclient import TestClient
|
5 |
from routes import query_handler, purchase, order_management, account_management, customer_support, search_products
|
6 |
|
7 |
app = FastAPI()
|
|
|
18 |
app.include_router(query_handler.router,
|
19 |
prefix="/query-handler", tags=["query-handler"])
|
20 |
|
21 |
+
# Initialize the TestClient with the FastAPI app
|
22 |
+
client = TestClient(app)
|
23 |
|
24 |
def fastlane_agent(message, history):
|
25 |
|
|
|
31 |
{"role": "assistant", "content": assistant})
|
32 |
history_openai_format.append({"role": "user", "content": message})
|
33 |
|
34 |
+
response = client.post("/query-handler/", json={"text": message, "history": history_openai_format})
|
|
|
35 |
if response.status_code == 200:
|
36 |
return response.json().get("generative response")
|
37 |
else:
|