Hansimov commited on
Commit
3ae76f6
·
1 Parent(s): b2e11d6

:recycle: [Refactor] Remove /chat route, and add /api for compatibility

Browse files
Files changed (1) hide show
  1. apis/chat_api.py +1 -46
apis/chat_api.py CHANGED
@@ -86,46 +86,6 @@ class ChatAPIApp:
86
  "conversation_id": creator.conversation_id,
87
  }
88
 
89
- class ChatPostItem(BaseModel):
90
- prompt: str = Field(
91
- default="Hello, who are you?",
92
- description="(str) Prompt",
93
- )
94
- model: str = Field(
95
- default="precise",
96
- description="(str) `precise`, `balanced`, `creative`, `precise-offline`, `balanced-offline`, `creative-offline`",
97
- )
98
- sec_access_token: str = Field(
99
- default="",
100
- description="(str) Sec Access Token",
101
- )
102
- client_id: str = Field(
103
- default="",
104
- description="(str) Client ID",
105
- )
106
- conversation_id: str = Field(
107
- default="",
108
- description="(str) Conversation ID",
109
- )
110
- invocation_id: int = Field(
111
- default=0,
112
- description="(int) Invocation ID",
113
- )
114
-
115
- def chat(self, item: ChatPostItem):
116
- connector = ConversationConnector(
117
- conversation_style=item.model,
118
- sec_access_token=item.sec_access_token,
119
- client_id=item.client_id,
120
- conversation_id=item.conversation_id,
121
- invocation_id=item.invocation_id,
122
- )
123
-
124
- return EventSourceResponse(
125
- connector.stream_chat(prompt=item.prompt, yield_output=True),
126
- media_type="text/event-stream",
127
- )
128
-
129
  class ChatCompletionsPostItem(BaseModel):
130
  model: str = Field(
131
  default="precise",
@@ -163,7 +123,7 @@ class ChatAPIApp:
163
  )
164
 
165
  def setup_routes(self):
166
- for prefix in ["", "/v1"]:
167
  self.app.get(
168
  prefix + "/models",
169
  summary="Get available models",
@@ -174,11 +134,6 @@ class ChatAPIApp:
174
  summary="Create a conversation session",
175
  )(self.create_conversation_session)
176
 
177
- self.app.post(
178
- prefix + "/chat",
179
- summary="Chat in conversation session",
180
- )(self.chat)
181
-
182
  self.app.post(
183
  prefix + "/chat/completions",
184
  summary="Chat completions in conversation session",
 
86
  "conversation_id": creator.conversation_id,
87
  }
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  class ChatCompletionsPostItem(BaseModel):
90
  model: str = Field(
91
  default="precise",
 
123
  )
124
 
125
  def setup_routes(self):
126
+ for prefix in ["", "/v1", "/api", "/api/v1"]:
127
  self.app.get(
128
  prefix + "/models",
129
  summary="Get available models",
 
134
  summary="Create a conversation session",
135
  )(self.create_conversation_session)
136
 
 
 
 
 
 
137
  self.app.post(
138
  prefix + "/chat/completions",
139
  summary="Chat completions in conversation session",