added cerebras
Browse files- together_ai_llama_agent.py +65 -6
together_ai_llama_agent.py
CHANGED
@@ -55,6 +55,40 @@ def get_csv_info(df: pd.DataFrame) -> dict:
|
|
55 |
return info
|
56 |
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
def get_csv_system_prompt(df: pd.DataFrame) -> str:
|
59 |
"""Generate system prompt for CSV analysis"""
|
60 |
csv_info = get_csv_info(df)
|
@@ -74,13 +108,38 @@ Strict Rules:
|
|
74 |
- Include necessary imports (except pandas) and include complete code
|
75 |
- Use df directly (e.g., print(df[...].mean()))
|
76 |
3. For visualizations:
|
77 |
-
-
|
78 |
-
-
|
79 |
-
-
|
80 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
- Do not use any visualization library other than matplotlib or seaborn
|
82 |
-
- Complete code with plt.show()
|
83 |
-
- Example
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
4. For Lists and Dictionaries, return them as JSON
|
85 |
|
86 |
Example:
|
|
|
55 |
return info
|
56 |
|
57 |
|
58 |
+
# def get_csv_system_prompt(df: pd.DataFrame) -> str:
|
59 |
+
# """Generate system prompt for CSV analysis"""
|
60 |
+
# csv_info = get_csv_info(df)
|
61 |
+
|
62 |
+
# prompt = f"""
|
63 |
+
# You're a CSV analysis assistant. The pandas DataFrame is loaded as 'df' - use this variable.
|
64 |
+
|
65 |
+
# CSV Info:
|
66 |
+
# - Rows: {csv_info['num_rows']}, Cols: {csv_info['num_cols']}
|
67 |
+
# - Columns: {csv_info['columns']}
|
68 |
+
# - Sample: {csv_info['example_rows']}
|
69 |
+
# - Dtypes: {csv_info['dtypes']}
|
70 |
+
|
71 |
+
# Strict Rules:
|
72 |
+
# 1. Never recreate 'df' - use the existing variable
|
73 |
+
# 2. For analysis:
|
74 |
+
# - Include necessary imports (except pandas) and include complete code
|
75 |
+
# - Use df directly (e.g., print(df[...].mean()))
|
76 |
+
# 3. For visualizations:
|
77 |
+
# - Adjust font sizes, rotate labels (45° if needed), truncate for readability
|
78 |
+
# - Figure size: (12, 6)
|
79 |
+
# - Descriptive titles (fontsize=14)
|
80 |
+
# - Colorblind-friendly palettes
|
81 |
+
# - Do not use any visualization library other than matplotlib or seaborn
|
82 |
+
# - Complete code with plt.show()
|
83 |
+
# - Example: plt.bar(df['x'], df['y']) \n plt.show()
|
84 |
+
# 4. For Lists and Dictionaries, return them as JSON
|
85 |
+
|
86 |
+
# Example:
|
87 |
+
# import json
|
88 |
+
# print(json.dumps(df[df['col'] == 'val'].to_dict('records'), indent=2))
|
89 |
+
# """
|
90 |
+
# return
|
91 |
+
|
92 |
def get_csv_system_prompt(df: pd.DataFrame) -> str:
|
93 |
"""Generate system prompt for CSV analysis"""
|
94 |
csv_info = get_csv_info(df)
|
|
|
108 |
- Include necessary imports (except pandas) and include complete code
|
109 |
- Use df directly (e.g., print(df[...].mean()))
|
110 |
3. For visualizations:
|
111 |
+
- Create the most professional, publication-quality charts possible
|
112 |
+
- Maximize descriptive elements and detail while maintaining clarity
|
113 |
+
- Figure size: (14, 8) for complex charts, (12, 6) for simpler ones
|
114 |
+
- Use comprehensive titles (fontsize=16) and axis labels (fontsize=14)
|
115 |
+
- Include informative legends (fontsize=12) when appropriate
|
116 |
+
- Add annotations for important data points where valuable
|
117 |
+
- Rotate x-labels (45° if needed) with fontsize=12 for readability
|
118 |
+
- Use colorblind-friendly palettes (seaborn 'deep', 'muted', or 'colorblind')
|
119 |
+
- Add gridlines (alpha=0.3) when they improve readability
|
120 |
+
- Include proper margins and padding to prevent label cutoff
|
121 |
+
- For distributions, include kernel density estimates when appropriate
|
122 |
+
- For time series, use appropriate date formatting and markers
|
123 |
- Do not use any visualization library other than matplotlib or seaborn
|
124 |
+
- Complete code with plt.tight_layout() before plt.show()
|
125 |
+
- Example professional chart:
|
126 |
+
plt.figure(figsize=(14, 8))
|
127 |
+
ax = sns.barplot(x='category', y='value', data=df, palette='muted', ci=None)
|
128 |
+
plt.title('Detailed Analysis of Values by Category', fontsize=16, pad=20)
|
129 |
+
plt.xlabel('Category', fontsize=14)
|
130 |
+
plt.ylabel('Average Value', fontsize=14)
|
131 |
+
plt.xticks(rotation=45, ha='right', fontsize=12)
|
132 |
+
plt.yticks(fontsize=12)
|
133 |
+
ax.grid(True, linestyle='--', alpha=0.3)
|
134 |
+
for p in ax.patches:
|
135 |
+
ax.annotate(f'{{p.get_height():.1f}}',
|
136 |
+
(p.get_x() + p.get_width() / 2., p.get_height()),
|
137 |
+
ha='center', va='center',
|
138 |
+
xytext=(0, 10),
|
139 |
+
textcoords='offset points',
|
140 |
+
fontsize=12)
|
141 |
+
plt.tight_layout()
|
142 |
+
plt.show()
|
143 |
4. For Lists and Dictionaries, return them as JSON
|
144 |
|
145 |
Example:
|