@@ -25,16 +25,15 @@ class AsyncPromptTemplateRepositoryMixin(AsyncRepositoryProtocol):
2525 """Prompt Template Repository for managing user and system default prompts"""
2626
2727 async def query_prompt_template (
28- self , prompt_type : str , scope : str , user_id : Optional [str ], language : str
28+ self , prompt_type : str , scope : str , user_id : Optional [str ]
2929 ) -> Optional [PromptTemplate ]:
3030 """
31- Query a single prompt template by type, scope, user_id and language .
31+ Query a single prompt template by type, scope, and user_id .
3232
3333 Args:
3434 prompt_type: Type of prompt (agent_system, agent_query, index_graph, etc.)
3535 scope: 'user' or 'system'
3636 user_id: User ID (required for scope='user', None for scope='system')
37- language: Language code (en-US, zh-CN)
3837
3938 Returns:
4039 PromptTemplate instance or None
@@ -44,7 +43,6 @@ async def _query(session):
4443 stmt = select (PromptTemplate ).where (
4544 PromptTemplate .prompt_type == prompt_type ,
4645 PromptTemplate .scope == scope ,
47- PromptTemplate .language == language ,
4846 PromptTemplate .gmt_deleted .is_ (None ),
4947 )
5048
@@ -58,51 +56,47 @@ async def _query(session):
5856
5957 return await self ._execute_query (_query )
6058
61- async def query_user_prompt_templates (self , user_id : str , language : Optional [ str ] = None ) -> List [PromptTemplate ]:
59+ async def query_user_prompt_templates (self , user_id : str ) -> List [PromptTemplate ]:
6260 """
6361 Query all prompt templates for a specific user.
6462
6563 Args:
6664 user_id: User ID
67- language: Optional language filter
6865
6966 Returns:
7067 List of PromptTemplate instances
7168 """
7269
7370 async def _query (session ):
74- stmt = select (PromptTemplate ).where (
75- PromptTemplate .scope == "user" , PromptTemplate .user_id == user_id , PromptTemplate .gmt_deleted .is_ (None )
71+ stmt = (
72+ select (PromptTemplate )
73+ .where (
74+ PromptTemplate .scope == "user" ,
75+ PromptTemplate .user_id == user_id ,
76+ PromptTemplate .gmt_deleted .is_ (None ),
77+ )
78+ .order_by (PromptTemplate .prompt_type )
7679 )
7780
78- if language :
79- stmt = stmt .where (PromptTemplate .language == language )
80-
81- stmt = stmt .order_by (PromptTemplate .prompt_type , PromptTemplate .language )
82-
8381 result = await session .execute (stmt )
8482 return result .scalars ().all ()
8583
8684 return await self ._execute_query (_query )
8785
88- async def query_system_prompt_templates (self , language : Optional [ str ] = None ) -> List [PromptTemplate ]:
86+ async def query_system_prompt_templates (self ) -> List [PromptTemplate ]:
8987 """
9088 Query all system default prompt templates.
9189
92- Args:
93- language: Optional language filter
94-
9590 Returns:
9691 List of PromptTemplate instances
9792 """
9893
9994 async def _query (session ):
100- stmt = select (PromptTemplate ).where (PromptTemplate .scope == "system" , PromptTemplate .gmt_deleted .is_ (None ))
101-
102- if language :
103- stmt = stmt .where (PromptTemplate .language == language )
104-
105- stmt = stmt .order_by (PromptTemplate .prompt_type , PromptTemplate .language )
95+ stmt = (
96+ select (PromptTemplate )
97+ .where (PromptTemplate .scope == "system" , PromptTemplate .gmt_deleted .is_ (None ))
98+ .order_by (PromptTemplate .prompt_type )
99+ )
106100
107101 result = await session .execute (stmt )
108102 return result .scalars ().all ()
@@ -114,7 +108,6 @@ async def create_or_update_prompt_template(
114108 prompt_type : str ,
115109 scope : str ,
116110 user_id : Optional [str ],
117- language : str ,
118111 content : str ,
119112 description : Optional [str ] = None ,
120113 ) -> PromptTemplate :
@@ -125,7 +118,6 @@ async def create_or_update_prompt_template(
125118 prompt_type: Type of prompt
126119 scope: 'user' or 'system'
127120 user_id: User ID (required for scope='user')
128- language: Language code
129121 content: Prompt content
130122 description: Optional description
131123
@@ -134,11 +126,9 @@ async def create_or_update_prompt_template(
134126 """
135127
136128 async def _operation (session ):
137- # Try to find existing template
138129 stmt = select (PromptTemplate ).where (
139130 PromptTemplate .prompt_type == prompt_type ,
140131 PromptTemplate .scope == scope ,
141- PromptTemplate .language == language ,
142132 PromptTemplate .gmt_deleted .is_ (None ),
143133 )
144134
@@ -151,18 +141,15 @@ async def _operation(session):
151141 instance = result .scalars ().first ()
152142
153143 if instance :
154- # Update existing
155144 instance .content = content
156145 if description is not None :
157146 instance .description = description
158147 instance .gmt_updated = utc_now ()
159148 else :
160- # Create new
161149 instance = PromptTemplate (
162150 prompt_type = prompt_type ,
163151 scope = scope ,
164152 user_id = user_id ,
165- language = language ,
166153 content = content ,
167154 description = description ,
168155 )
@@ -174,15 +161,14 @@ async def _operation(session):
174161
175162 return await self .execute_with_transaction (_operation )
176163
177- async def delete_prompt_template (self , prompt_type : str , scope : str , user_id : Optional [str ], language : str ) -> bool :
164+ async def delete_prompt_template (self , prompt_type : str , scope : str , user_id : Optional [str ]) -> bool :
178165 """
179166 Soft delete a prompt template.
180167
181168 Args:
182169 prompt_type: Type of prompt
183170 scope: 'user' or 'system'
184171 user_id: User ID (required for scope='user')
185- language: Language code
186172
187173 Returns:
188174 True if deleted, False if not found
@@ -192,7 +178,6 @@ async def _operation(session):
192178 stmt = select (PromptTemplate ).where (
193179 PromptTemplate .prompt_type == prompt_type ,
194180 PromptTemplate .scope == scope ,
195- PromptTemplate .language == language ,
196181 PromptTemplate .gmt_deleted .is_ (None ),
197182 )
198183
0 commit comments