Skip to content

add default embed dimen #523

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public class EmbeddingInputModel : MessageConfig
public IEnumerable<string> Texts { get; set; } = new List<string>();

[JsonPropertyName("dimension")]
public int Dimension { get; set; }
public int Dimension { get; set; } = 1536;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ public class TextEmbeddingProvider : ITextEmbedding
protected readonly IServiceProvider _services;
protected readonly ILogger<TextEmbeddingProvider> _logger;

private const int DEFAULT_DIMENSION = 1536;
protected string _model;

public virtual string Provider => "azure-openai";

public int Dimension { get; set; } = 4096;
public int Dimension { get; set; }

public TextEmbeddingProvider(
AzureOpenAiSettings settings,
Expand Down Expand Up @@ -59,13 +60,12 @@ private EmbeddingGenerationOptions PrepareOptions()

private int GetDimension()
{
var defaultDimension = 4096;
var state = _services.GetRequiredService<IConversationStateService>();
var stateDimension = state.GetState("embedding_state");
var stateDimension = state.GetState("embedding_dimension");
if (int.TryParse(stateDimension, out var dimension))
{
return dimension > 0 ? dimension : defaultDimension;
return dimension > 0 ? dimension :(Dimension > 0 ? Dimension: DEFAULT_DIMENSION);
}
return Dimension > 0 ? Dimension : defaultDimension;
return Dimension > 0 ? Dimension : DEFAULT_DIMENSION;
}
}