feat: add config for embedding model (#12120)
This PR adds the ability to modify the embedding model used by Captain AI.Previously, the embedding model was hardcoded which led to errors when you used a different API provider which did not support that specific embedding model. Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
This commit is contained in:
@@ -3,9 +3,11 @@ require 'openai'
|
||||
class Captain::Llm::EmbeddingService < Llm::BaseOpenAiService
|
||||
class EmbeddingsError < StandardError; end
|
||||
|
||||
DEFAULT_MODEL = 'text-embedding-3-small'.freeze
|
||||
def self.embedding_model
|
||||
@embedding_model = InstallationConfig.find_by(name: 'CAPTAIN_EMBEDDING_MODEL')&.value.presence || OpenAiConstants::DEFAULT_EMBEDDING_MODEL
|
||||
end
|
||||
|
||||
def get_embedding(content, model: DEFAULT_MODEL)
|
||||
def get_embedding(content, model: self.class.embedding_model)
|
||||
response = @client.embeddings(
|
||||
parameters: {
|
||||
model: model,
|
||||
|
||||
Reference in New Issue
Block a user