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

Function get_post_handler

apps/chat/serializers/chat.py:100–132  ·  view source on GitHub ↗
(chat_info: ChatInfo)

Source from the content-addressed store, hash-verified

98
99
100def get_post_handler(chat_info: ChatInfo):
101 class PostHandler(PostResponseHandler):
102
103 def handler(self,
104 chat_id,
105 chat_record_id,
106 paragraph_list: List[Paragraph],
107 problem_text: str,
108 answer_text,
109 manage: PipelineManage,
110 step: BaseChatStep,
111 padding_problem_text: str = None,
112 **kwargs):
113 answer_list = [[Answer(answer_text, 'ai-chat-node', 'ai-chat-node', 'ai-chat-node', {}, 'ai-chat-node',
114 kwargs.get('reasoning_content', '')).to_dict()]]
115 chat_record = ChatRecord(id=chat_record_id,
116 chat_id=chat_id,
117 problem_text=problem_text,
118 answer_text=answer_text,
119 details=manage.get_details(),
120 message_tokens=manage.context['message_tokens'],
121 answer_tokens=manage.context['answer_tokens'],
122 answer_text_list=answer_list,
123 run_time=manage.context['run_time'],
124 index=len(chat_info.chat_record_list) + 1,
125 ip_address=chat_info.ip_address,
126 source=chat_info.source
127 )
128 chat_info.append_chat_record(chat_record)
129 # 重新设置缓存
130 chat_info.set_cache()
131
132 return PostHandler()
133
134
135class DebugChatSerializers(serializers.Serializer):

Callers 1

chat_simpleMethod · 0.85

Calls 1

PostHandlerClass · 0.85

Tested by

no test coverage detected