Update app.py
Browse files
app.py
CHANGED
@@ -12,8 +12,7 @@ os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'
|
|
12 |
torch.cuda.empty_cache()
|
13 |
torch.cuda.set_per_process_memory_fraction(0.8) # Adjust the fraction as needed
|
14 |
|
15 |
-
app = FastAPI(
|
16 |
-
app.add_middleware(CORSMiddleware, allow_origins=['*'], allow_methods=['*'], allow_headers=['*'],)
|
17 |
|
18 |
ngrok.set_auth_token("1XtU01EKWysplGQ8fz54lVUQpnQ_3KKhw6YNQ5E85rxdkgXx4e")
|
19 |
ngrok.kill()
|
@@ -106,7 +105,7 @@ async def api_home():
|
|
106 |
|
107 |
|
108 |
# Endpoint to start a new conversation thread
|
109 |
-
@app.post('/
|
110 |
async def start_conversation(request: Request):
|
111 |
data = await request.json()
|
112 |
prompt = data.get('prompt')
|
@@ -125,7 +124,7 @@ async def start_conversation(request: Request):
|
|
125 |
# Endpoint to get the response of a conversation thread
|
126 |
|
127 |
|
128 |
-
@app.get('/
|
129 |
async def get_response(thread_id: int):
|
130 |
if thread_id not in conversations:
|
131 |
raise HTTPException(status_code=404, detail="Thread not found")
|
@@ -141,7 +140,7 @@ async def get_response(thread_id: int):
|
|
141 |
|
142 |
|
143 |
|
144 |
-
@app.post('/
|
145 |
async def chat(request: Request):
|
146 |
data = await request.json()
|
147 |
prompt = data.get('prompt')
|
|
|
12 |
torch.cuda.empty_cache()
|
13 |
torch.cuda.set_per_process_memory_fraction(0.8) # Adjust the fraction as needed
|
14 |
|
15 |
+
app = FastAPI(root_path="/api/v1")
|
|
|
16 |
|
17 |
ngrok.set_auth_token("1XtU01EKWysplGQ8fz54lVUQpnQ_3KKhw6YNQ5E85rxdkgXx4e")
|
18 |
ngrok.kill()
|
|
|
105 |
|
106 |
|
107 |
# Endpoint to start a new conversation thread
|
108 |
+
@app.post('/start_conversation/')
|
109 |
async def start_conversation(request: Request):
|
110 |
data = await request.json()
|
111 |
prompt = data.get('prompt')
|
|
|
124 |
# Endpoint to get the response of a conversation thread
|
125 |
|
126 |
|
127 |
+
@app.get('/get_response/{thread_id}')
|
128 |
async def get_response(thread_id: int):
|
129 |
if thread_id not in conversations:
|
130 |
raise HTTPException(status_code=404, detail="Thread not found")
|
|
|
140 |
|
141 |
|
142 |
|
143 |
+
@app.post('/chat/')
|
144 |
async def chat(request: Request):
|
145 |
data = await request.json()
|
146 |
prompt = data.get('prompt')
|