mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: The OpenAI interface supports the thought process (#2392)
This commit is contained in:
parent
dfcb724502
commit
8c45e92ee4
|
|
@ -22,8 +22,11 @@ class OpenaiToResponse(BaseToResponse):
|
|||
def to_block_response(self, chat_id, chat_record_id, content, is_end, completion_tokens, prompt_tokens,
|
||||
other_params: dict = None,
|
||||
_status=status.HTTP_200_OK):
|
||||
if other_params is None:
|
||||
other_params = {}
|
||||
data = ChatCompletion(id=chat_record_id, choices=[
|
||||
BlockChoice(finish_reason='stop', index=0, chat_id=chat_id,
|
||||
reasoning_content=other_params.get('reasoning_content', ""),
|
||||
message=ChatCompletionMessage(role='assistant', content=content))],
|
||||
created=datetime.datetime.now().second, model='', object='chat.completion',
|
||||
usage=CompletionUsage(completion_tokens=completion_tokens,
|
||||
|
|
@ -32,11 +35,16 @@ class OpenaiToResponse(BaseToResponse):
|
|||
).dict()
|
||||
return JsonResponse(data=data, status=_status)
|
||||
|
||||
def to_stream_chunk_response(self, chat_id, chat_record_id, node_id, up_node_id_list, content, is_end, completion_tokens,
|
||||
def to_stream_chunk_response(self, chat_id, chat_record_id, node_id, up_node_id_list, content, is_end,
|
||||
completion_tokens,
|
||||
prompt_tokens, other_params: dict = None):
|
||||
if other_params is None:
|
||||
other_params = {}
|
||||
chunk = ChatCompletionChunk(id=chat_record_id, model='', object='chat.completion.chunk',
|
||||
created=datetime.datetime.now().second,choices=[
|
||||
Choice(delta=ChoiceDelta(content=content, chat_id=chat_id), finish_reason='stop' if is_end else None,
|
||||
created=datetime.datetime.now().second, choices=[
|
||||
Choice(delta=ChoiceDelta(content=content, reasoning_content=other_params.get('reasoning_content', ""),
|
||||
chat_id=chat_id),
|
||||
finish_reason='stop' if is_end else None,
|
||||
index=0)],
|
||||
usage=CompletionUsage(completion_tokens=completion_tokens,
|
||||
prompt_tokens=prompt_tokens,
|
||||
|
|
|
|||
Loading…
Reference in New Issue