kanno927 commited on
Commit
ef5e6f9
·
1 Parent(s): 93e9960

feature(#134): Fix lint error

Browse files
Brain/src/common/assembler.py CHANGED
@@ -82,5 +82,5 @@ class Assembler:
82
  return {
83
  "contactId": contact.contact_id,
84
  "displayName": contact.display_name,
85
- "phoneNumbers": contact.phone_numbers
86
  }
 
82
  return {
83
  "contactId": contact.contact_id,
84
  "displayName": contact.display_name,
85
+ "phoneNumbers": contact.phone_numbers,
86
  }
Brain/src/model/requests/request_model.py CHANGED
@@ -15,10 +15,10 @@ class ClientInfo:
15
 
16
  def is_browser(self) -> bool:
17
  if (
18
- self.browser == "Chrome"
19
- or self.browser == "Firefox"
20
- or self.browser == "Safari"
21
- or self.browser == "Edge"
22
  ):
23
  return True
24
  return False
 
15
 
16
  def is_browser(self) -> bool:
17
  if (
18
+ self.browser == "Chrome"
19
+ or self.browser == "Firefox"
20
+ or self.browser == "Safari"
21
+ or self.browser == "Edge"
22
  ):
23
  return True
24
  return False
Brain/src/router/api.py CHANGED
@@ -18,7 +18,8 @@ from Brain.src.model.requests.request_model import (
18
  BasicReq,
19
  ClientInfo,
20
  get_client_info,
21
- AutoTaskDelete, GetContactsByIds,
 
22
  )
23
  from Brain.src.rising_plugin.risingplugin import (
24
  getCompletion,
@@ -61,7 +62,7 @@ def construct_blueprint_api() -> APIRouter:
61
 
62
  @router.post("/sendNotification")
63
  def send_notification(
64
- data: Notification, client_info: ClientInfo = Depends(get_client_info)
65
  ):
66
  # firebase admin init
67
  try:
@@ -90,7 +91,9 @@ def construct_blueprint_api() -> APIRouter:
90
 
91
  # check contact querying
92
  try:
93
- contacts_service = ContactsService(firebase_app=firebase_app, setting=setting)
 
 
94
  if result["program"] == ProgramType.AUTO_TASK:
95
  auto_task_service = AutoTaskService()
96
  result["content"] = auto_task_service.ask_task_with_autogpt(
@@ -194,7 +197,7 @@ def construct_blueprint_api() -> APIRouter:
194
  try:
195
  # check about asking image description with trained data
196
  if query_image_ask(
197
- image_content=image_content, message=message, setting=setting
198
  ):
199
  image_response["image_desc"] = image_content
200
  else:
@@ -413,7 +416,9 @@ def construct_blueprint_api() -> APIRouter:
413
  for contact in data.contacts:
414
  contacts.append(assembler.to_contact_model(contact))
415
  # train contact
416
- contacts_service = ContactsService(firebase_app=firebase_app, setting=setting)
 
 
417
  contacts_service.train(uuid, contacts)
418
  except Exception as e:
419
  if isinstance(e, BrainException):
@@ -444,7 +449,9 @@ def construct_blueprint_api() -> APIRouter:
444
 
445
  # parsing contacts
446
  # train contact
447
- contacts_service = ContactsService(firebase_app=firebase_app, setting=setting)
 
 
448
  contacts_service.delete_all(uuid)
449
  except Exception as e:
450
  if isinstance(e, BrainException):
@@ -518,11 +525,10 @@ def construct_blueprint_api() -> APIRouter:
518
  token: str = setting.token
519
  uuid: str = setting.uuid
520
 
521
- result = ContactsService(firebase_app=firebase_app, setting=setting).getContactsByIds(uuid=uuid,
522
- contactIds=data.contactIds)
 
523
 
524
- return assembler.to_response(
525
- 200, "Success to get contacts by uuid", result
526
- )
527
 
528
  return router
 
18
  BasicReq,
19
  ClientInfo,
20
  get_client_info,
21
+ AutoTaskDelete,
22
+ GetContactsByIds,
23
  )
24
  from Brain.src.rising_plugin.risingplugin import (
25
  getCompletion,
 
62
 
63
  @router.post("/sendNotification")
64
  def send_notification(
65
+ data: Notification, client_info: ClientInfo = Depends(get_client_info)
66
  ):
67
  # firebase admin init
68
  try:
 
91
 
92
  # check contact querying
93
  try:
94
+ contacts_service = ContactsService(
95
+ firebase_app=firebase_app, setting=setting
96
+ )
97
  if result["program"] == ProgramType.AUTO_TASK:
98
  auto_task_service = AutoTaskService()
99
  result["content"] = auto_task_service.ask_task_with_autogpt(
 
197
  try:
198
  # check about asking image description with trained data
199
  if query_image_ask(
200
+ image_content=image_content, message=message, setting=setting
201
  ):
202
  image_response["image_desc"] = image_content
203
  else:
 
416
  for contact in data.contacts:
417
  contacts.append(assembler.to_contact_model(contact))
418
  # train contact
419
+ contacts_service = ContactsService(
420
+ firebase_app=firebase_app, setting=setting
421
+ )
422
  contacts_service.train(uuid, contacts)
423
  except Exception as e:
424
  if isinstance(e, BrainException):
 
449
 
450
  # parsing contacts
451
  # train contact
452
+ contacts_service = ContactsService(
453
+ firebase_app=firebase_app, setting=setting
454
+ )
455
  contacts_service.delete_all(uuid)
456
  except Exception as e:
457
  if isinstance(e, BrainException):
 
525
  token: str = setting.token
526
  uuid: str = setting.uuid
527
 
528
+ result = ContactsService(
529
+ firebase_app=firebase_app, setting=setting
530
+ ).getContactsByIds(uuid=uuid, contactIds=data.contactIds)
531
 
532
+ return assembler.to_response(200, "Success to get contacts by uuid", result)
 
 
533
 
534
  return router
Brain/src/service/contact_service.py CHANGED
@@ -1,7 +1,6 @@
1
  """service to manage contacts"""
2
  from typing import List, Any
3
 
4
- import google
5
 
6
  from Brain.src.common.assembler import Assembler
7
  from Brain.src.model.req_model import ReqModel
@@ -114,7 +113,9 @@ class ContactsService:
114
  assembler = Assembler()
115
  data = assembler.to_contact_result_format(contact)
116
  phones_doc_ref = self.phones_ref.document(uuid)
117
- contacts_doc_ref = phones_doc_ref.collection("contacts").document(contact.contact_id)
 
 
118
  contacts_doc_ref.set(data)
119
 
120
  """update a contact into document which name is uuid in phone collections in firestore"""
@@ -123,14 +124,18 @@ class ContactsService:
123
  assembler = Assembler()
124
  data = assembler.to_contact_result_format(contact)
125
  phones_doc_ref = self.phones_ref.document(uuid)
126
- contacts_doc_ref = phones_doc_ref.collection("contacts").document(contact.contact_id)
 
 
127
  contacts_doc_ref.update(data)
128
 
129
  """delete a contact into document which name is uuid in phone collections in firestore"""
130
 
131
  def delete_one_contact(self, uuid: str, contact: ContactModel):
132
  phones_doc_ref = self.phones_ref.document(uuid)
133
- contacts_doc_ref = phones_doc_ref.collection("contacts").document(contact.contact_id)
 
 
134
  contacts_doc_ref.delete()
135
 
136
  def getContactsByIds(self, uuid: str, contactIds: list[str]) -> []:
 
1
  """service to manage contacts"""
2
  from typing import List, Any
3
 
 
4
 
5
  from Brain.src.common.assembler import Assembler
6
  from Brain.src.model.req_model import ReqModel
 
113
  assembler = Assembler()
114
  data = assembler.to_contact_result_format(contact)
115
  phones_doc_ref = self.phones_ref.document(uuid)
116
+ contacts_doc_ref = phones_doc_ref.collection("contacts").document(
117
+ contact.contact_id
118
+ )
119
  contacts_doc_ref.set(data)
120
 
121
  """update a contact into document which name is uuid in phone collections in firestore"""
 
124
  assembler = Assembler()
125
  data = assembler.to_contact_result_format(contact)
126
  phones_doc_ref = self.phones_ref.document(uuid)
127
+ contacts_doc_ref = phones_doc_ref.collection("contacts").document(
128
+ contact.contact_id
129
+ )
130
  contacts_doc_ref.update(data)
131
 
132
  """delete a contact into document which name is uuid in phone collections in firestore"""
133
 
134
  def delete_one_contact(self, uuid: str, contact: ContactModel):
135
  phones_doc_ref = self.phones_ref.document(uuid)
136
+ contacts_doc_ref = phones_doc_ref.collection("contacts").document(
137
+ contact.contact_id
138
+ )
139
  contacts_doc_ref.delete()
140
 
141
  def getContactsByIds(self, uuid: str, contactIds: list[str]) -> []: