liuhua liuhua commited on
Commit
5b3c777
·
1 Parent(s): 5403bcb

Add a default value for do_refer in Dialog (#2383)

Browse files

### What problem does this PR solve?

Add a default value for do_refer in Dialog

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---------

Co-authored-by: liuhua <[email protected]>

api/db/db_models.py CHANGED
@@ -830,6 +830,7 @@ class Dialog(DataBaseModel):
830
  do_refer = CharField(
831
  max_length=1,
832
  null=False,
 
833
  help_text="it needs to insert reference index into answer or not")
834
 
835
  rerank_id = CharField(
 
830
  do_refer = CharField(
831
  max_length=1,
832
  null=False,
833
+ default="1",
834
  help_text="it needs to insert reference index into answer or not")
835
 
836
  rerank_id = CharField(
api/db/services/api_service.py CHANGED
@@ -14,7 +14,9 @@
14
  # limitations under the License.
15
  #
16
  from datetime import datetime
 
17
  import peewee
 
18
  from api.db.db_models import DB, API4Conversation, APIToken, Dialog
19
  from api.db.services.common_service import CommonService
20
  from api.utils import current_timestamp, datetime_format
@@ -41,7 +43,7 @@ class API4ConversationService(CommonService):
41
  @DB.connection_context()
42
  def append_message(cls, id, conversation):
43
  cls.update_by_id(id, conversation)
44
- return cls.model.update(round=cls.model.round + 1).where(cls.model.id==id).execute()
45
 
46
  @classmethod
47
  @DB.connection_context()
@@ -61,7 +63,7 @@ class API4ConversationService(CommonService):
61
  cls.model.round).alias("round"),
62
  peewee.fn.SUM(
63
  cls.model.thumb_up).alias("thumb_up")
64
- ).join(Dialog, on=(cls.model.dialog_id == Dialog.id & Dialog.tenant_id == tenant_id)).where(
65
  cls.model.create_date >= from_date,
66
  cls.model.create_date <= to_date,
67
  cls.model.source == source
 
14
  # limitations under the License.
15
  #
16
  from datetime import datetime
17
+
18
  import peewee
19
+
20
  from api.db.db_models import DB, API4Conversation, APIToken, Dialog
21
  from api.db.services.common_service import CommonService
22
  from api.utils import current_timestamp, datetime_format
 
43
  @DB.connection_context()
44
  def append_message(cls, id, conversation):
45
  cls.update_by_id(id, conversation)
46
+ return cls.model.update(round=cls.model.round + 1).where(cls.model.id == id).execute()
47
 
48
  @classmethod
49
  @DB.connection_context()
 
63
  cls.model.round).alias("round"),
64
  peewee.fn.SUM(
65
  cls.model.thumb_up).alias("thumb_up")
66
+ ).join(Dialog, on=((cls.model.dialog_id == Dialog.id) & (Dialog.tenant_id == tenant_id))).where(
67
  cls.model.create_date >= from_date,
68
  cls.model.create_date <= to_date,
69
  cls.model.source == source