mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
优化请求内容上下文及顺序
This commit is contained in:
@@ -1057,7 +1057,6 @@ MY
|
|||||||
風騷欲女
|
風騷欲女
|
||||||
毛郭伯雄
|
毛郭伯雄
|
||||||
一九八九年六月四日
|
一九八九年六月四日
|
||||||
game master
|
|
||||||
龟头操进处女阴道
|
龟头操进处女阴道
|
||||||
浪少妇和医生疯狂做爱
|
浪少妇和医生疯狂做爱
|
||||||
狭义道
|
狭义道
|
||||||
@@ -1838,7 +1837,6 @@ tiang tang
|
|||||||
喇嘛
|
喇嘛
|
||||||
體奸
|
體奸
|
||||||
u r靠
|
u r靠
|
||||||
game MASTER
|
|
||||||
海盗时代
|
海盗时代
|
||||||
我和姨在车上干
|
我和姨在车上干
|
||||||
赌马
|
赌马
|
||||||
@@ -5158,7 +5156,6 @@ renminbao
|
|||||||
RMB
|
RMB
|
||||||
少妇房中自淫,和两勇男玩17P,操得直叫爽 操日本淫女穴
|
少妇房中自淫,和两勇男玩17P,操得直叫爽 操日本淫女穴
|
||||||
淫奸护士姐姐穴
|
淫奸护士姐姐穴
|
||||||
game
|
|
||||||
情色电影网站
|
情色电影网站
|
||||||
錘子
|
錘子
|
||||||
民主墙
|
民主墙
|
||||||
|
|||||||
@@ -35,18 +35,20 @@ class Channel(models.Model):
|
|||||||
domain += [('date', '>=', afterTime)]
|
domain += [('date', '>=', afterTime)]
|
||||||
ai_msg_list = message_model.with_context(tz='UTC').search(domain, order="id desc", limit=chat_count)
|
ai_msg_list = message_model.with_context(tz='UTC').search(domain, order="id desc", limit=chat_count)
|
||||||
for ai_msg in ai_msg_list:
|
for ai_msg in ai_msg_list:
|
||||||
# todo: 判断这个 ai_msg 是不是ai发,有才 insert。 判断 user_msg 是不是 user发的,有才 insert
|
# 判断这个 ai_msg 是不是ai发,有才 insert。 判断 user_msg 是不是 user发的,有才 insert
|
||||||
user_msg = ai_msg.parent_id
|
user_msg = ai_msg.parent_id
|
||||||
user_content = user_msg.description.replace("<p>", "").replace("</p>", "").replace('@%s' % answer_id.name, '').lstrip()
|
if ai_msg.author_id.gpt_id:
|
||||||
ai_content = str(ai_msg.body).replace("<p>", "").replace("</p>", "").replace("<p>", "")
|
ai_content = str(ai_msg.body).replace("<p>", "").replace("</p>", "").replace("<p>", "")
|
||||||
context_history.insert(0, {
|
context_history.insert(0, {
|
||||||
'role': 'assistant',
|
'role': 'assistant',
|
||||||
'content': ai_content,
|
'content': ai_content,
|
||||||
})
|
})
|
||||||
context_history.insert(0, {
|
if not user_msg.author_id.gpt_id:
|
||||||
'role': 'user',
|
user_content = user_msg.description.replace("<p>", "").replace("</p>", "").replace('@%s' % answer_id.name, '').lstrip()
|
||||||
'content': user_content,
|
context_history.insert(0, {
|
||||||
})
|
'role': 'user',
|
||||||
|
'content': user_content,
|
||||||
|
})
|
||||||
return context_history
|
return context_history
|
||||||
|
|
||||||
def get_ai_response(self, ai, messages, channel, user_id, message):
|
def get_ai_response(self, ai, messages, channel, user_id, message):
|
||||||
@@ -130,10 +132,11 @@ class Channel(models.Model):
|
|||||||
channel = self
|
channel = self
|
||||||
|
|
||||||
try:
|
try:
|
||||||
messages = [{"role": "user", "content": msg}]
|
messages = []
|
||||||
c_history = self.get_openai_context(channel.id, author_id, answer_id, openapi_context_timeout, chat_count)
|
c_history = self.get_openai_context(channel.id, author_id, answer_id, openapi_context_timeout, chat_count)
|
||||||
if c_history:
|
if c_history:
|
||||||
messages += c_history
|
messages += c_history
|
||||||
|
messages.append({"role": "user", "content": msg})
|
||||||
if sync_config == 'sync':
|
if sync_config == 'sync':
|
||||||
self.get_ai_response(ai, messages, channel, user_id, message)
|
self.get_ai_response(ai, messages, channel, user_id, message)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user