Spaces:
Sleeping
Sleeping
changed csv format
Browse files- config.py +1 -0
- src/chat.py +7 -16
config.py
CHANGED
|
@@ -6,6 +6,7 @@ load_dotenv()
|
|
| 6 |
|
| 7 |
|
| 8 |
BASE_MODEL = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
|
|
|
|
| 9 |
# Other options:
|
| 10 |
# MODEL = "meta-llama/Llama-2-7b-chat-hf"
|
| 11 |
# MODEL = "openlm-research/open_llama_3b"
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
BASE_MODEL = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
|
| 9 |
+
# BASE_MODEL = "meta-llama/Llama-3-8b-chat-hf"
|
| 10 |
# Other options:
|
| 11 |
# MODEL = "meta-llama/Llama-2-7b-chat-hf"
|
| 12 |
# MODEL = "openlm-research/open_llama_3b"
|
src/chat.py
CHANGED
|
@@ -32,7 +32,6 @@ class SchoolChatbot:
|
|
| 32 |
def format_school_data(
|
| 33 |
school_csv='BPS.csv',
|
| 34 |
programs_csv='BPS-special-programs.csv',
|
| 35 |
-
max_schools=None
|
| 36 |
):
|
| 37 |
"""
|
| 38 |
Merges main school data with special program indicators and formats it for in-context prompting.
|
|
@@ -50,28 +49,20 @@ class SchoolChatbot:
|
|
| 50 |
schools_df = pd.read_csv(school_csv)
|
| 51 |
programs_df = pd.read_csv(programs_csv)
|
| 52 |
|
| 53 |
-
# Merge on School Name
|
| 54 |
merged_df = pd.merge(schools_df, programs_df, on="School Name", how="left")
|
| 55 |
|
| 56 |
-
#
|
| 57 |
-
if max_schools:
|
| 58 |
-
merged_df = merged_df.head(max_schools)
|
| 59 |
-
|
| 60 |
school_lines = []
|
| 61 |
for _, row in merged_df.iterrows():
|
| 62 |
# Collect all programs marked "Yes"
|
| 63 |
programs_offered = [col for col in programs_df.columns[1:] if row.get(col, "") == "Yes"]
|
| 64 |
-
programs_str = "
|
| 65 |
|
| 66 |
school_lines.append(
|
| 67 |
-
f'-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
f' Type: {row["School Type"]}\n'
|
| 71 |
-
f' Contact: {row["Email Address"]}, {row["Phone Number"]}\n'
|
| 72 |
-
f' Programs: {programs_str}'
|
| 73 |
-
)
|
| 74 |
-
|
| 75 |
return "# SCHOOL_DATA\n" + "\n".join(school_lines)
|
| 76 |
|
| 77 |
except Exception as e:
|
|
@@ -117,8 +108,8 @@ class SchoolChatbot:
|
|
| 117 |
school_data_section = SchoolChatbot.format_school_data(
|
| 118 |
school_csv=self.school_csv,
|
| 119 |
programs_csv=self.programs_csv,
|
| 120 |
-
max_schools=30
|
| 121 |
)
|
|
|
|
| 122 |
|
| 123 |
examples_section = """# EXAMPLES
|
| 124 |
User: My child is turning 5 on August 15 and we live in 02124. What grade can they enter, and what schools are available?
|
|
|
|
| 32 |
def format_school_data(
|
| 33 |
school_csv='BPS.csv',
|
| 34 |
programs_csv='BPS-special-programs.csv',
|
|
|
|
| 35 |
):
|
| 36 |
"""
|
| 37 |
Merges main school data with special program indicators and formats it for in-context prompting.
|
|
|
|
| 49 |
schools_df = pd.read_csv(school_csv)
|
| 50 |
programs_df = pd.read_csv(programs_csv)
|
| 51 |
|
| 52 |
+
# Merge on School Name
|
| 53 |
merged_df = pd.merge(schools_df, programs_df, on="School Name", how="left")
|
| 54 |
|
| 55 |
+
# Use more concise formatting
|
|
|
|
|
|
|
|
|
|
| 56 |
school_lines = []
|
| 57 |
for _, row in merged_df.iterrows():
|
| 58 |
# Collect all programs marked "Yes"
|
| 59 |
programs_offered = [col for col in programs_df.columns[1:] if row.get(col, "") == "Yes"]
|
| 60 |
+
programs_str = "Y" if programs_offered else "N"
|
| 61 |
|
| 62 |
school_lines.append(
|
| 63 |
+
f'- {row["School Name"]}: {row["Grades Served"]}, {row["School Type"]}, {programs_str}'
|
| 64 |
+
)
|
| 65 |
+
school_lines = list(set(school_lines)) # Remove duplicates
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
return "# SCHOOL_DATA\n" + "\n".join(school_lines)
|
| 67 |
|
| 68 |
except Exception as e:
|
|
|
|
| 108 |
school_data_section = SchoolChatbot.format_school_data(
|
| 109 |
school_csv=self.school_csv,
|
| 110 |
programs_csv=self.programs_csv,
|
|
|
|
| 111 |
)
|
| 112 |
+
print(school_data_section)
|
| 113 |
|
| 114 |
examples_section = """# EXAMPLES
|
| 115 |
User: My child is turning 5 on August 15 and we live in 02124. What grade can they enter, and what schools are available?
|