mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-26 17:42:15 +00:00
FEATURE: basic support for GPT-o models (#804)
Caveats - No streaming, by design - No tool support (including no XML tools) - No vision Open AI will revamt the model and more of these features may become available. This solution is a bit hacky for now
This commit is contained in:
parent
493d65af1f
commit
4b21eb7974
@ -39,6 +39,11 @@ module DiscourseAi
|
|||||||
llm_model.max_prompt_tokens - buffer
|
llm_model.max_prompt_tokens - buffer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# no support for streaming or tools or system messages
|
||||||
|
def is_gpt_o?
|
||||||
|
llm_model.provider == "open_ai" && llm_model.name.include?("o1-")
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def tools_dialect
|
def tools_dialect
|
||||||
@ -46,7 +51,11 @@ module DiscourseAi
|
|||||||
end
|
end
|
||||||
|
|
||||||
def system_msg(msg)
|
def system_msg(msg)
|
||||||
{ role: "system", content: msg[:content] }
|
if is_gpt_o?
|
||||||
|
{ role: "user", content: msg[:content] }
|
||||||
|
else
|
||||||
|
{ role: "system", content: msg[:content] }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def model_msg(msg)
|
def model_msg(msg)
|
||||||
|
@ -27,6 +27,17 @@ module DiscourseAi
|
|||||||
AiApiAuditLog::Provider::OpenAI
|
AiApiAuditLog::Provider::OpenAI
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def perform_completion!(dialect, user, model_params = {}, feature_name: nil, &blk)
|
||||||
|
if dialect.respond_to?(:is_gpt_o?) && dialect.is_gpt_o? && block_given?
|
||||||
|
# we need to disable streaming and simulate it
|
||||||
|
blk.call "", lambda { |*| }
|
||||||
|
response = super(dialect, user, model_params, feature_name: feature_name, &nil)
|
||||||
|
blk.call response, lambda { |*| }
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def model_uri
|
def model_uri
|
||||||
|
Loading…
x
Reference in New Issue
Block a user