Skip to content

Commit

Permalink
fix: conversation none error
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouhaoJiang committed Jun 25, 2024
1 parent 27c2446 commit 0971768
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions api/core/ops/ops_trace_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ def get_decrypted_tracing_config(cls, app_id: str, tracing_provider: str):
@classmethod
def get_ops_trace_instance(
cls,
app_id: Union[UUID, str] = None,
message_id: str = None,
conversation_id: str = None
app_id: Optional[Union[UUID, str]] = None,
message_id: Optional[str] = None,
conversation_id: Optional[str] = None
):
"""
Get ops trace through model config
Expand All @@ -161,20 +161,23 @@ def get_ops_trace_instance(
:param conversation_id: conversation_id
:return:
"""
if conversation_id:
if conversation_id is not None:
conversation_data: Conversation = db.session.query(Conversation).filter(
Conversation.id == conversation_id
).first()
app_id = conversation_data.app_id
if conversation_data:
app_id = conversation_data.app_id

if message_id:
if message_id is not None:
record: Message = db.session.query(Message).filter(Message.id == message_id).first()
app_id = record.app_id

if isinstance(app_id, UUID):
app_id = str(app_id)

tracing_instance = None
if app_id is None:
return None

app: App = db.session.query(App).filter(
App.id == app_id
).first()
Expand Down

0 comments on commit 0971768

Please sign in to comment.