Skip to content

Commit 4b35640

Browse files
committed
refactor: enhance logging and refine language analysis process in MatMaster agent for improved clarity and accuracy
1 parent 50b9d63 commit 4b35640

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

agents/matmaster_agent/callback.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import inspect
12
import json
23
import logging
34
import uuid
@@ -50,7 +51,7 @@ async def matmaster_set_lang(callback_context: CallbackContext) -> Optional[type
5051
response = litellm.completion(model='azure/gpt-4o', messages=[{'role': 'user', 'content': prompt}],
5152
response_format=UserContent)
5253
result: dict = json.loads(response.choices[0].message.content)
53-
logger.info(f"[matmaster_prepare_state] user_content = {result}")
54+
logger.info(f"[{inspect.currentframe().f_code.co_name}] result = {result}")
5455
language = str(result.get('language', 'zh'))
5556
callback_context.state['target_language'] = language
5657

agents/matmaster_agent/prompt.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,13 +804,30 @@ def get_params_check_info_prompt():
804804

805805
def get_user_content_lang():
806806
return """
807-
You are a professional assistant responsible for analysing language of user_content.
807+
You are a professional linguistic analyst. Your task is to identify the primary language used in the user content provided.
808808
809809
User Content:
810810
{user_content}
811811
812-
Provide your analysis in the following JSON format:
812+
Analyze the text and determine the most likely language from the following predefined options:
813+
- English
814+
- Chinese
815+
- Spanish
816+
- French
817+
- German
818+
- Japanese
819+
- Korean
820+
- Russian
821+
- Arabic
822+
- Portuguese
823+
- Italian
824+
- Dutch
825+
- Other
826+
827+
If the language does not clearly match any of the above options or is a mix of multiple languages, classify it as "Other".
828+
829+
Provide your analysis in the following strict JSON format:
813830
{{
814-
"language": <string>
831+
"language": "<string>"
815832
}}
816833
"""

0 commit comments

Comments
 (0)