Skip to content
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

fix model groq empty. change default max tokens. #306

Merged
merged 1 commit into from
May 17, 2024
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
1 change: 1 addition & 0 deletions src/Providers/Groq/src/GroqChatModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public override async Task<ChatResponse> GenerateAsync(
{
request = request ?? throw new ArgumentNullException(nameof(request));
var prompt = ToPrompt(request.Messages);
Provider.Api.SetModel(Id);
var watch = Stopwatch.StartNew();
var response = await Provider.Api.CreateChatCompletionAsync(prompt).ConfigureAwait(false);

Expand Down
2 changes: 1 addition & 1 deletion src/Providers/Groq/src/GroqConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class GroqConfiguration
public string ApiKey { get; set; } = string.Empty;
public string ModelId { get; set; } = string.Empty;
public double Temperature { get; set; } = 0.5;
public int MaxTokens { get; set; } = int.MaxValue;
public int MaxTokens { get; set; } = 8192 ;
public double TopP { get; set; } = 1.0;
public string Stop { get; set; } = "NONE";
public int StructuredRetryPolicy { get; set; } = 5;
Expand Down
3 changes: 1 addition & 2 deletions src/Providers/Groq/src/GroqProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ public GroqProvider(GroqConfiguration configuration)
{
configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
var apiKey = configuration.ApiKey ?? throw new ArgumentException("ApiKey is not defined", nameof(configuration));
var apiModel = configuration.ModelId ?? throw new ArgumentException("ModelId is not defined", nameof(configuration));

Api = new GroqClient(apiKey, apiModel)
Api = new GroqClient(apiKey, configuration.ModelId)
.SetTemperature(configuration.Temperature)
.SetMaxTokens(configuration.MaxTokens)
.SetTopP(configuration.TopP)
Expand Down
5 changes: 3 additions & 2 deletions src/Providers/Groq/test/GroqTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ public async Task Chat()
var config = new GroqConfiguration()
{
ApiKey = Environment.GetEnvironmentVariable("GROQ_API_KEY") ??
throw new InconclusiveException("GROQ_API_KEY is not set."),
ModelId = "llama3-70b-8192"
throw new InconclusiveException("GROQ_API_KEY is not set.")
};

var provider = new GroqProvider(config);
var model = new Llama370B(provider);

string answer = await model.GenerateAsync("Generate some random name:");

answer.Should().NotBeNull();

Console.WriteLine(answer);
}
}
Loading