(20250120) Mail sending API ready.

This commit is contained in:
2025-01-20 14:14:02 +05:30
parent 1f8e13e1d5
commit f6636afe59
8 changed files with 442 additions and 73 deletions
+17 -3
View File
@@ -44,6 +44,9 @@ from utils_v2.string import json
from utils_v2.string import regex
from utils_v2.date_time import date_time
# To work with MongoDB:
from bson.objectid import ObjectId
# To work with date and time:
import datetime
@@ -133,8 +136,8 @@ class LLMInput(BaseModel):
# Verify that there is AT MOST ONE 'system' message,
# and verify that the 'system' message is the first message:
if system_message_count > 1: raise ValueError(f"there can be at most 1 'system' message, found {system_message_count}")
if system_message_index > 0: raise ValueError(f"'system' message must always be at index 0, found it at index {system_message_index}")
if system_message_count > 1: raise ValueError(f"There can be at most 1 'system' message: found {system_message_count}")
if system_message_index > 0: raise ValueError(f"The 'system' message must always be at index 0; found it at index {system_message_index}")
# Done here:
return value
@@ -207,7 +210,7 @@ class LLMOutput(BaseModel):
frozen = True
)
invocationId: Any | None = Field(
invocationId: ObjectId | str | None = Field(
description = "the id of the document that notes this invocation; useful for reconciliation",
frozen = False,
default = None
@@ -220,6 +223,17 @@ class LLMOutput(BaseModel):
class Config:
extra = "forbid"
arbitrary_types_allowed = True
# ┓┏ ┓• ┓ •
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓
# ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗
@field_validator("invocationId", mode = "before")
def parse_oid(cls, value):
try: value = ObjectId(value)
except: pass
return value
# ┏┓ •
# ┃┃┏┓┏┓┏┓┏┓┏┓╋┓┏┓┏