Skip to content

Commit

Permalink
minor enforcement of CSV length for internal processing (#3109)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodanswer authored Nov 23, 2024
1 parent 5dfafc8 commit 694e79f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backend/danswer/llm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ def translate_history_to_basemessages(
return history_basemessages, history_token_counts


def _process_csv_file(file: InMemoryChatFile) -> str:
# Processes CSV files to show the first 5 rows and max_columns (default 40) columns
def _process_csv_file(file: InMemoryChatFile, max_columns: int = 40) -> str:
df = pd.read_csv(io.StringIO(file.content.decode("utf-8")))
csv_preview = df.head().to_string()

csv_preview = df.head().to_string(max_cols=max_columns)

file_name_section = (
f"CSV FILE NAME: {file.filename}\n"
Expand Down

0 comments on commit 694e79f

Please sign in to comment.