mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Fix "Messages is invalid" error for Ollama/custom LLM providers and add comprehensive AI documentation (#225)
* Add comprehensive AI/LLM configuration documentation * Fix Chat.start! to use default model when model is nil or empty * Ensure all controllers use Chat.default_model for consistency * Move AI doc inside `hosting/` * Probably too much error handling --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com> Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
This commit is contained in:
@@ -23,11 +23,18 @@ class Assistant
|
||||
ai_model: message.ai_model
|
||||
)
|
||||
|
||||
llm_provider = get_model_provider(message.ai_model)
|
||||
|
||||
unless llm_provider
|
||||
error_message = build_no_provider_error_message(message.ai_model)
|
||||
raise StandardError, error_message
|
||||
end
|
||||
|
||||
responder = Assistant::Responder.new(
|
||||
message: message,
|
||||
instructions: instructions,
|
||||
function_tool_caller: function_tool_caller,
|
||||
llm: get_model_provider(message.ai_model)
|
||||
llm: llm_provider
|
||||
)
|
||||
|
||||
latest_response_id = chat.latest_assistant_response_id
|
||||
@@ -72,4 +79,23 @@ class Assistant
|
||||
|
||||
@function_tool_caller ||= FunctionToolCaller.new(function_instances)
|
||||
end
|
||||
|
||||
def build_no_provider_error_message(requested_model)
|
||||
available_providers = registry.providers
|
||||
|
||||
if available_providers.empty?
|
||||
"No LLM provider configured that supports model '#{requested_model}'. " \
|
||||
"Please configure an LLM provider (e.g., OpenAI) in settings."
|
||||
else
|
||||
provider_details = available_providers.map do |provider|
|
||||
" - #{provider.provider_name}: #{provider.supported_models_description}"
|
||||
end.join("\n")
|
||||
|
||||
"No LLM provider configured that supports model '#{requested_model}'.\n\n" \
|
||||
"Available providers:\n#{provider_details}\n\n" \
|
||||
"Please either:\n" \
|
||||
" 1. Use a supported model from the list above, or\n" \
|
||||
" 2. Configure a provider that supports '#{requested_model}' in settings."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user