Skip to content

Commit

Permalink
Merge branch 'fix/ops-trace-celery' into deploy/dev
Browse files Browse the repository at this point in the history
* fix/ops-trace-celery:
  feat: add delete file finally
  chore: remove convert_datetime_to_str
  fix: optimizing code
  • Loading branch information
ZhouhaoJiang committed Nov 15, 2024
2 parents 8cc63ff + 36cf784 commit f21f88a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
10 changes: 1 addition & 9 deletions api/core/ops/ops_trace_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
)
from core.ops.langfuse_trace.langfuse_trace import LangFuseDataTrace
from core.ops.langsmith_trace.langsmith_trace import LangSmithDataTrace
from core.ops.utils import convert_datetime_to_str, get_message_data
from core.ops.utils import get_message_data
from extensions.ext_database import db
from extensions.ext_storage import storage
from models.model import App, AppModelConfig, Conversation, Message, MessageAgentThought, MessageFile, TraceAppConfig
Expand Down Expand Up @@ -756,12 +756,4 @@ def send_to_celery(self, tasks: list[TraceTask]):
"file_id": file_id,
"app_id": task.app_id,
}
task_data = convert_datetime_to_str(task_data)
json_data = json.dumps(task_data, ensure_ascii=False).encode("utf-8")
file_path = f"{OPS_FILE_PATH}{task.app_id}/{file_id}.json"
storage.save(file_path, json_data)
file_info = {
"file_id": file_id,
"app_id": task.app_id,
}
process_trace_tasks.delay(file_info)
14 changes: 0 additions & 14 deletions api/core/ops/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,3 @@ def replace_text_with_content(data):
return [replace_text_with_content(item) for item in data]
else:
return data


def convert_datetime_to_str(data):
if isinstance(data, dict):
for key, value in data.items():
if isinstance(value, datetime):
data[key] = value.isoformat()
elif isinstance(value, dict):
data[key] = convert_datetime_to_str(value)
elif isinstance(value, list):
data[key] = [convert_datetime_to_str(item) if isinstance(item, dict | list) else item for item in value]
elif isinstance(data, list):
data = [convert_datetime_to_str(item) if isinstance(item, dict | list) else item for item in data]
return data

0 comments on commit f21f88a

Please sign in to comment.