Skip to content

Commit

Permalink
update gateway-docsum
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa <[email protected]>
  • Loading branch information
MSCetin37 committed Nov 9, 2024
1 parent c314778 commit c3c2d5f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions comps/cores/mega/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,19 +409,19 @@ async def handle_request(self, request: Request):
class DocSumGateway(Gateway):
def __init__(self, megaservice, host="0.0.0.0", port=8888):
super().__init__(
megaservice,
host,
port,
str(MegaServiceEndpoint.DOC_SUMMARY),
input_datatype=DocSumChatCompletionRequest,
output_datatype=ChatCompletionResponse,
megaservice,
host,
port,
str(MegaServiceEndpoint.DOC_SUMMARY),
input_datatype= DocSumChatCompletionRequest,
output_datatype=ChatCompletionResponse
)

async def handle_request(self, request: Request, files: List[UploadFile] = File(default=None)):
async def handle_request(self, request: Request):
data = await request.json()
stream_opt = data.get("stream", True)
stream_opt = data.get("stream", True)
chat_request = ChatCompletionRequest.model_validate(data)

prompt = self._handle_message(chat_request.messages)
parameters = LLMParams(
max_tokens=chat_request.max_tokens if chat_request.max_tokens else 1024,
Expand All @@ -432,10 +432,9 @@ async def handle_request(self, request: Request, files: List[UploadFile] = File(
presence_penalty=chat_request.presence_penalty if chat_request.presence_penalty else 0.0,
repetition_penalty=chat_request.repetition_penalty if chat_request.repetition_penalty else 1.03,
streaming=stream_opt,
language=chat_request.language if chat_request.language else "auto",
)
result_dict, runtime_graph = await self.megaservice.schedule(
initial_inputs={data["type"]: prompt}, llm_parameters=parameters
initial_inputs={data['type']: prompt}, llm_parameters=parameters
)
for node, response in result_dict.items():
# Here it suppose the last microservice in the megaservice is LLM.
Expand All @@ -459,6 +458,7 @@ async def handle_request(self, request: Request, files: List[UploadFile] = File(
return ChatCompletionResponse(model="docsum", choices=choices, usage=usage)



class AudioQnAGateway(Gateway):
def __init__(self, megaservice, host="0.0.0.0", port=8888):
super().__init__(
Expand Down

0 comments on commit c3c2d5f

Please sign in to comment.