-
Notifications
You must be signed in to change notification settings - Fork 31
lang instruction to beginning of prompt #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -50,7 +50,13 @@ def create_llm_service(llm_config: Dict[str, Any]): | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| logger.info(f'Creating LLM service: {llm_type} / {model}') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if llm_type == 'openai': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return LLMServiceFactory._create_openai_llm(api_key, model, parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| base_url = llm_config.get('base_url') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not base_url or base_url == 'https://api.openai.com/v1': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return LLMServiceFactory._create_openai_llm(api_key, model, parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return LLMServiceFactory._create_openai_compatible_llm( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| api_key, model, parameters, base_url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif llm_type == 'azure_openai': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| base_url = llm_config.get('base_url') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not base_url: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -97,6 +103,36 @@ def _create_openai_llm(api_key: str, model: str, parameters: Dict[str, Any]): | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return OpenAILLMService(api_key=api_key, model=model, params=input_params) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @staticmethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _create_openai_compatible_llm( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| api_key: str, model: str, parameters: Dict[str, Any], base_url: str | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Create a BaseOpenAILLMService for OpenAI-compatible endpoints""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params_dict = {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if 'temperature' in parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params_dict['temperature'] = parameters['temperature'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if 'max_completion_tokens' in parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params_dict['max_completion_tokens'] = parameters['max_completion_tokens'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if 'top_p' in parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params_dict['top_p'] = parameters['top_p'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if 'frequency_penalty' in parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params_dict['frequency_penalty'] = parameters['frequency_penalty'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if 'presence_penalty' in parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params_dict['presence_penalty'] = parameters['presence_penalty'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if 'seed' in parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params_dict['seed'] = parameters['seed'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+113
to
+125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In Line 113–125 mapping, Suggested fix if 'seed' in parameters:
params_dict['seed'] = parameters['seed']
+ if 'service_tier' in parameters:
+ params_dict['service_tier'] = parameters['service_tier']📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input_params = BaseOpenAILLMService.InputParams(**params_dict) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logger.info( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| f"OpenAI-compatible LLM config: model={model}, base_url={base_url}, temp={params_dict.get('temperature', 'default')}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return BaseOpenAILLMService( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| api_key=api_key, model=model, base_url=base_url, params=input_params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @staticmethod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _create_google_llm(api_key: str, model: str, parameters: Dict[str, Any]): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Create Google LLM service""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normalize
base_urlbefore default-endpoint comparison.On Line 54, raw string comparison can misroute equivalent default URLs (e.g., trailing slash/whitespace) into the OpenAI-compatible path.
Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents