Skip to content

Commit

Permalink
create endpoint for suggesting data types
Browse files Browse the repository at this point in the history
  • Loading branch information
liberty-rising committed Jan 27, 2024
1 parent e58d983 commit 02cade8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions backend/llms/gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,17 @@ async def generate_chart_config(

return parsed_config

async def generate_suggested_column_types(self, data: dict):
"""Generate suggested column types for the given data."""
self._add_system_message(assistant_type="column_type_suggestion")
self._set_response_format(is_json=True)

prompt = self.prompt_manager.create_column_type_suggestion_prompt(data)

gpt_response = await self._send_and_receive_message(prompt)

return gpt_response

def fetch_table_name_from_sample(
self, sample_content: str, extra_desc: str, table_metadata: str
):
Expand Down
8 changes: 8 additions & 0 deletions backend/routes/data_profile_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ async def preview_data_profile(
return extracted_data


# @data_profile_router.post("/data-profiles/preview/column-types/")
# async def generate_suggested_column_types(
# data, current_user: User = Depends(get_current_user)
# ):
# gpt = GPTLLM(chat_id=1, user=current_user)
# suggested_column_types = await gpt.generate_suggested_column_types(data)


@data_profile_router.post("/data-profiles/{data_profile_name}/preview/")
async def preview_data_profile_upload(
data_profile_name: str,
Expand Down

0 comments on commit 02cade8

Please sign in to comment.