-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
37 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
increment_response_count, | ||
thread_emails_to_openai_messages, | ||
) | ||
from server.models.document import Document | ||
from server.models.email import Email | ||
from server.models.response import Response | ||
from server.models.thread import Thread | ||
|
@@ -28,8 +29,9 @@ def email(): | |
thread = Thread() | ||
db.session.add(thread) | ||
db.session.commit() | ||
|
||
email = Email( | ||
date=datetime.datetime.now(datetime.timezone.utc), | ||
date=datetime.datetime.now(datetime.timezone.utc), # type: ignore | ||
sender="[email protected]", | ||
subject=subject, | ||
body=body, | ||
|
@@ -46,14 +48,26 @@ def email(): | |
questions, document_ids, document_confidences = document_data(documents) | ||
db.session.add(email) | ||
db.session.commit() | ||
|
||
documents = [] | ||
for i, doc_ids_question in enumerate(document_ids): | ||
documents.append([]) | ||
for doc_id in doc_ids_question: | ||
document = db.session.execute( | ||
db.select(Document).where(Document.id == doc_id) | ||
).scalar() | ||
if document: | ||
documents[i].append(document) | ||
|
||
r = Response( | ||
openai_res, | ||
questions, | ||
document_ids, | ||
documents, | ||
document_confidences, | ||
confidence, | ||
email.id, | ||
) | ||
|
||
db.session.add(r) | ||
thread.last_email = email.id | ||
thread.resolved = False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters