Skip to content

Commit e53303b

Browse files
committed
feat: thin the prompt and correct some variable
1 parent 2c17dde commit e53303b

File tree

1 file changed

+8
-33
lines changed

1 file changed

+8
-33
lines changed

β€Žwren-ai-service/src/pipelines/generation/semantics_enrichment.py

+8-33
Original file line numberDiff line numberDiff line change
@@ -88,27 +88,27 @@ def wrapper(text: str) -> str:
8888

8989

9090
## End of Pipeline
91-
class ModelProperties(BaseModel):
91+
class Properties(BaseModel):
9292
alias: str
9393
description: str
9494

9595

9696
class ModelColumns(BaseModel):
9797
name: str
98-
properties: ModelProperties
98+
properties: Properties
9999

100100

101101
class SemanticModel(BaseModel):
102102
name: str
103103
columns: list[ModelColumns]
104-
properties: ModelProperties
104+
properties: Properties
105105

106106

107107
class SemanticResult(BaseModel):
108108
models: list[SemanticModel]
109109

110110

111-
semantics_enrichment_KWARGS = {
111+
SEMANTICS_ENRICHMENT_KWARGS = {
112112
"response_format": {
113113
"type": "json_schema",
114114
"json_schema": {
@@ -137,34 +137,9 @@ class SemanticResult(BaseModel):
137137
- Aliases should be intuitive and user-friendly
138138
- Use the user's context to inform the descriptions
139139
- Maintain technical accuracy while being accessible to non-technical users
140-
141-
Output Format:
142-
{
143-
"models": [{
144-
"name": "model",
145-
"columns": [{
146-
"name": "column",
147-
"properties": {
148-
"alias": "User-friendly column name",
149-
"description": "Clear explanation of column purpose"
150-
}
151-
}],
152-
"properties": {
153-
"alias": "User-friendly model name",
154-
"description": "Clear explanation of model purpose"
155-
}
156-
}]
157-
}
158-
159-
Example:
160-
Input model "orders" with column "created_at" might become:
161-
{
162-
"name": "created_at",
163-
"properties": {
164-
"alias": "Order Creation Date",
165-
"description": "Timestamp when the order was first created in the system"
166-
}
167-
}
140+
- IMPORTANT: Never modify the model/table and column names in the 'name' field as this will invalidate the data model
141+
- Only update the 'alias' field to provide user-friendly display names
142+
- When the user prompt includes operators to modify names, apply those modifications to the alias field only
168143
169144
Focus on providing business value through clear, accurate descriptions while maintaining JSON structure integrity.
170145
"""
@@ -185,7 +160,7 @@ def __init__(self, llm_provider: LLMProvider, **_):
185160
"prompt_builder": PromptBuilder(template=user_prompt_template),
186161
"generator": llm_provider.get_generator(
187162
system_prompt=system_prompt,
188-
generation_kwargs=semantics_enrichment_KWARGS,
163+
generation_kwargs=SEMANTICS_ENRICHMENT_KWARGS,
189164
),
190165
}
191166
self._final = "normalize"

0 commit comments

Comments
Β (0)