-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Support Chinese characters in prompt generation stage (#1168)
Update dataframe_serializer.py add test case to #1168
- Loading branch information
1 parent
456ff73
commit cd3bf42
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import unittest | ||
|
||
import pandas as pd | ||
|
||
from pandasai.connectors import PandasConnector | ||
from pandasai.helpers.dataframe_serializer import ( | ||
DataframeSerializer, | ||
DataframeSerializerType, | ||
) | ||
|
||
|
||
class TestDataframeSerializer(unittest.TestCase): | ||
def setUp(self): | ||
self.serializer = DataframeSerializer() | ||
|
||
def test_convert_df_to_yml(self): | ||
# Test convert df to yml | ||
data = {"name": ["en_name", "中文_名称"]} | ||
connector = PandasConnector( | ||
{"original_df": pd.DataFrame(data)}, | ||
name="en_table_name", | ||
description="中文_描述", | ||
field_descriptions={k: k for k in data}, | ||
) | ||
result = self.serializer.serialize( | ||
connector, | ||
type_=DataframeSerializerType.YML, | ||
extras={"index": 0, "type": "pd.Dataframe"}, | ||
) | ||
self.assertIn("中文_描述", result) |