MCPcopy
hub / github.com/1Panel-dev/MaxKB / SystemToResponse

Class SystemToResponse

apps/common/handle/impl/response/system_to_response.py:17–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17class SystemToResponse(BaseToResponse):
18 def to_block_response(self, chat_id, chat_record_id, content, is_end, completion_tokens,
19 prompt_tokens, other_params: dict = None,
20 _status=status.HTTP_200_OK):
21 if other_params is None:
22 other_params = {}
23 return result.success({'chat_id': str(chat_id), 'id': str(chat_record_id), 'operate': True,
24 'content': content, 'is_end': is_end, **other_params,
25 'completion_tokens': completion_tokens, 'prompt_tokens': prompt_tokens},
26 response_status=_status,
27 code=_status)
28
29 def to_stream_chunk_response(self, chat_id, chat_record_id, node_id, up_node_id_list, content, is_end,
30 completion_tokens,
31 prompt_tokens, other_params: dict = None):
32 if other_params is None:
33 other_params = {}
34 chunk = json.dumps({'chat_id': str(chat_id), 'chat_record_id': str(chat_record_id), 'operate': True,
35 'content': content, 'node_id': node_id, 'up_node_id_list': up_node_id_list,
36 'is_end': is_end,
37 'usage': {'completion_tokens': completion_tokens,
38 'prompt_tokens': prompt_tokens,
39 'total_tokens': completion_tokens + prompt_tokens},
40 **other_params})
41 return super().format_stream_chunk(chunk)

Callers 8

chatMethod · 0.90
chatMethod · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected