| 136 | |
| 137 | @dataclass |
| 138 | class TablePromptData: |
| 139 | name: str |
| 140 | schema: list |
| 141 | sample: list |
| 142 | annotation: TableDescription |
| 143 | |
| 144 | def render(self): |
| 145 | fmt_schema = "\n".join([str(field) for field in self.schema]) |
| 146 | ret = f"""## Information for Table '{self.name}' ## |
| 147 | |
| 148 | Schema:\n{fmt_schema} |
| 149 | |
| 150 | Sample rows:\n{format_rows_from_table(self.sample)}""" |
| 151 | if self.annotation: |
| 152 | ret += f"\nUsage Notes:\n{self.annotation.description}" |
| 153 | return ret |
| 154 | |
| 155 | |
| 156 | def build_prompt(db_connection, assistant_request, included_tables, query_error=None, sql=None): |