|
1 | 1 | from src.api.prompts.types import Prompt |
2 | | -from src.api.responses import prompt_response |
3 | 2 |
|
4 | | - |
5 | | -@prompt_response |
6 | | -def sql_optimization_prompt(query: str, database_type: str = "singlestore") -> str: |
7 | | - """ |
8 | | - Generate a prompt for SQL query optimization analysis. |
9 | | -
|
10 | | - Args: |
11 | | - query: The SQL query to optimize |
12 | | - database_type: The type of database (default: singlestore) |
13 | | - """ |
14 | | - return f""" |
15 | | - Please analyze and optimize the following {database_type.upper()} SQL query: |
16 | | -
|
17 | | - ```sql |
18 | | - {query} |
19 | | - ``` |
20 | | -
|
21 | | - Consider the following optimization strategies: |
22 | | - 1. Index usage and recommendations |
23 | | - 2. Query structure improvements |
24 | | - 3. JOIN optimization |
25 | | - 4. WHERE clause efficiency |
26 | | - 5. SingleStore-specific optimizations (if applicable) |
27 | | -
|
28 | | - Provide: |
29 | | - - Optimized query version |
30 | | - - Explanation of changes |
31 | | - - Performance impact estimation |
32 | | - - Index recommendations |
33 | | - """ |
34 | | - |
35 | | - |
36 | | -@prompt_response |
37 | | -def data_modeling_prompt( |
38 | | - table_description: str, use_case: str = "analytics", scale: str = "medium" |
39 | | -) -> str: |
40 | | - """ |
41 | | - Generate a prompt for SingleStore data modeling guidance. |
42 | | -
|
43 | | - Args: |
44 | | - table_description: Description of the data to model |
45 | | - use_case: The primary use case (analytics, transactional, hybrid) |
46 | | - scale: Expected data scale (small, medium, large, enterprise) |
47 | | - """ |
48 | | - return f""" |
49 | | - Design an optimal SingleStore data model for the following requirements: |
50 | | -
|
51 | | - **Data Description:** {table_description} |
52 | | - **Use Case:** {use_case} |
53 | | - **Scale:** {scale} |
54 | | -
|
55 | | - Please provide: |
56 | | - 1. **Table Schema Design** |
57 | | - - Column definitions with appropriate data types |
58 | | - - Primary key strategy |
59 | | - - Distribution key recommendations |
60 | | - - Sort key optimization |
61 | | -
|
62 | | - 2. **SingleStore-Specific Optimizations** |
63 | | - - Columnstore vs Rowstore recommendations |
64 | | - - Partitioning strategy |
65 | | - - Shard key selection |
66 | | - - Reference table considerations |
67 | | -
|
68 | | - 3. **Performance Considerations** |
69 | | - - Query pattern optimization |
70 | | - - Index strategy |
71 | | - - Memory usage optimization |
72 | | - - Scaling recommendations |
73 | | -
|
74 | | - 4. **Best Practices** |
75 | | - - Data ingestion patterns |
76 | | - - ETL considerations |
77 | | - - Monitoring and maintenance |
78 | | -
|
79 | | - Ensure the design leverages SingleStore's distributed architecture and hybrid transactional/analytical capabilities. |
80 | | - """ |
81 | | - |
82 | | - |
83 | | -prompts_definitions = [ |
84 | | - { |
85 | | - "title": "SQL Query Optimization Assistant", |
86 | | - "func": sql_optimization_prompt, |
87 | | - }, |
88 | | - { |
89 | | - "title": "SingleStore Data Modeling Guide", |
90 | | - "func": data_modeling_prompt, |
91 | | - }, |
92 | | -] |
| 3 | +prompts_definitions = [] |
93 | 4 |
|
94 | 5 | # Export the prompts using create_from_dict for consistency |
95 | 6 | prompts = [Prompt.create_from_dict(prompt) for prompt in prompts_definitions] |
0 commit comments