darabos commited on
Commit
e05fb8f
·
1 Parent(s): 57f808e

Take remaining path from request.state.

Browse files
examples/LynxScribe/ChatAPI/demo.py CHANGED
@@ -80,8 +80,8 @@ class ChatAPIService:
80
  model="gpt-4o-mini",
81
  )
82
 
83
- async def get(self, request: fastapi.Request, path: str) -> dict:
84
- if path == "models":
85
  return {
86
  "object": "list",
87
  "data": [
@@ -96,8 +96,8 @@ class ChatAPIService:
96
  }
97
  return {"error": "Not found"}
98
 
99
- async def post(self, request: fastapi.Request, path: str) -> dict:
100
- if path == "chat/completions":
101
  request = await request.json()
102
  if request["stream"]:
103
  from sse_starlette.sse import EventSourceResponse
 
80
  model="gpt-4o-mini",
81
  )
82
 
83
+ async def get(self, request: fastapi.Request) -> dict:
84
+ if request.state.remaining_path == "models":
85
  return {
86
  "object": "list",
87
  "data": [
 
96
  }
97
  return {"error": "Not found"}
98
 
99
+ async def post(self, request: fastapi.Request) -> dict:
100
+ if request.state.remaining_path == "chat/completions":
101
  request = await request.json()
102
  if request["stream"]:
103
  from sse_starlette.sse import EventSourceResponse
examples/LynxScribe/MCP/demo.py CHANGED
@@ -114,8 +114,8 @@ class ChatAPIService:
114
  max_tool_call_steps=999,
115
  )
116
 
117
- async def get(self, request: fastapi.Request, path: str) -> dict:
118
- if path == "models":
119
  return {
120
  "object": "list",
121
  "data": [
@@ -130,8 +130,8 @@ class ChatAPIService:
130
  }
131
  return {"error": "Not found"}
132
 
133
- async def post(self, request: fastapi.Request, path: str) -> dict:
134
- if path == "chat/completions":
135
  request = await request.json()
136
  assert not request["stream"]
137
  await self.init()
 
114
  max_tool_call_steps=999,
115
  )
116
 
117
+ async def get(self, request: fastapi.Request) -> dict:
118
+ if request.state.remaining_path == "models":
119
  return {
120
  "object": "list",
121
  "data": [
 
130
  }
131
  return {"error": "Not found"}
132
 
133
+ async def post(self, request: fastapi.Request) -> dict:
134
+ if request.state.remaining_path == "chat/completions":
135
  request = await request.json()
136
  assert not request["stream"]
137
  await self.init()