feat: Add LOCAL variable support for responses with UTF-8 JSON encoding.
Description: This feature adds support for UTF-8 encoding in JSON responses, allowing for proper handling of special characters and emojis. - Implement unit tests for UTF-8 encoding in various model providers including Gemini, OpenAI, and OpenAI Compatible. - Validate UTF-8 support in token counting, content generation, and error handling. - Introduce tests for JSON serialization ensuring proper handling of French characters and emojis. - Create tests for language instruction generation based on locale settings. - Validate UTF-8 handling in workflow tools including AnalyzeTool, CodereviewTool, and DebugIssueTool. - Ensure that all tests check for correct UTF-8 character preservation and proper JSON formatting. - Add integration tests to verify the interaction between locale settings and model responses.
This commit is contained in:
@@ -372,24 +372,24 @@ class SimpleTool(BaseTool):
|
||||
|
||||
follow_up_instructions = get_follow_up_instructions(0)
|
||||
prompt = f"{prompt}\n\n{follow_up_instructions}"
|
||||
logger.debug(f"Added follow-up instructions for new {self.get_name()} conversation")
|
||||
|
||||
# Validate images if any were provided
|
||||
logger.debug(f"Added follow-up instructions for new {self.get_name()} conversation") # Validate images if any were provided
|
||||
if images:
|
||||
image_validation_error = self._validate_image_limits(
|
||||
images, model_context=self._model_context, continuation_id=continuation_id
|
||||
)
|
||||
if image_validation_error:
|
||||
return [TextContent(type="text", text=json.dumps(image_validation_error))]
|
||||
return [TextContent(
|
||||
type="text",
|
||||
text=json.dumps(image_validation_error, ensure_ascii=False)
|
||||
)]
|
||||
|
||||
# Get and validate temperature against model constraints
|
||||
temperature, temp_warnings = self.get_validated_temperature(request, self._model_context)
|
||||
|
||||
# Log any temperature corrections
|
||||
for warning in temp_warnings:
|
||||
# Get thinking mode with defaults
|
||||
logger.warning(warning)
|
||||
|
||||
# Get thinking mode with defaults
|
||||
thinking_mode = self.get_request_thinking_mode(request)
|
||||
if thinking_mode is None:
|
||||
thinking_mode = self.get_default_thinking_mode()
|
||||
@@ -398,7 +398,9 @@ class SimpleTool(BaseTool):
|
||||
provider = self._model_context.provider
|
||||
|
||||
# Get system prompt for this tool
|
||||
system_prompt = self.get_system_prompt()
|
||||
base_system_prompt = self.get_system_prompt()
|
||||
language_instruction = self.get_language_instruction()
|
||||
system_prompt = language_instruction + base_system_prompt
|
||||
|
||||
# Generate AI response using the provider
|
||||
logger.info(f"Sending request to {provider.get_provider_type().value} API for {self.get_name()}")
|
||||
|
||||
Reference in New Issue
Block a user