Skip to content

Commit

Permalink
fix import
Browse files Browse the repository at this point in the history
  • Loading branch information
azliu0 committed Jun 27, 2024
1 parent 99bd3b8 commit 0798dbd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions server/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
from ast import literal_eval
from typing import cast

import pandas as pd
from apiflask import APIBlueprint
Expand Down Expand Up @@ -149,10 +150,10 @@ def import_csv():

for _, row in df.iterrows():
document = Document(
"" if pd.isna(row["question"]) else row["question"], # type: ignore
row["content"], # type: ignore
row["source"], # type: ignore
"" if pd.isna(row["label"]) else row["label"], # type: ignore
question=cast(str, "" if pd.isna(row["question"]) else row["question"]), # type: ignore
content=cast(str, row["content"]),
source=cast(str, row["source"]),
label=cast(str, "" if pd.isna(row["label"]) else row["label"]), # type: ignore
)
db.session.add(document)
db.session.commit()
Expand Down

0 comments on commit 0798dbd

Please sign in to comment.