Skip to content

Commit 8bd5b56

Browse files
authored
Merge pull request #210 from databyjp/bugfix/model-configs-review-pt2
2 parents 42c3dd2 + cc022a0 commit 8bd5b56

File tree

5 files changed

+64
-7
lines changed

5 files changed

+64
-7
lines changed

src/Weaviate.Client/Models/Generative/Providers.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,15 @@ public record XAI() : Weaviate.Client.Models.GenerativeProvider("xai")
171171
public List<string>? Images { get; set; }
172172
public List<string>? ImageProperties { get; set; }
173173
}
174+
175+
public record ContextualAI() : Weaviate.Client.Models.GenerativeProvider("contextualai")
176+
{
177+
public string? Model { get; set; }
178+
public double? Temperature { get; set; }
179+
public double? TopP { get; set; }
180+
public long? MaxNewTokens { get; set; }
181+
public string? SystemPrompt { get; set; }
182+
public bool? AvoidCommentary { get; set; }
183+
public string[]? Knowledge { get; set; }
184+
}
174185
}

src/Weaviate.Client/Models/GenerativeConfig.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ public record Custom : IGenerativeConfig
1919

2020
public abstract record OpenAIBase : IGenerativeConfig
2121
{
22+
public string? Model { get; set; }
2223
public string? BaseURL { get; set; }
2324
public int? FrequencyPenalty { get; set; }
2425
public int? MaxTokens { get; set; }
2526
public int? PresencePenalty { get; set; }
2627
public double? Temperature { get; set; }
2728
public double? TopP { get; set; }
2829
public string? ApiVersion { get; set; }
30+
public string? ReasoningEffort { get; set; }
31+
public string? Verbosity { get; set; }
2932
public abstract string Type { get; }
3033
}
3134

@@ -144,10 +147,6 @@ public record OpenAI : OpenAIBase
144147
{
145148
public const string TypeValue = "generative-openai";
146149
public override string Type => TypeValue;
147-
148-
public string? Model { get; set; }
149-
public string? ReasoningEffort { get; set; }
150-
public string? Verbosity { get; set; }
151150
}
152151

153152
public record AzureOpenAI : OpenAIBase
@@ -187,4 +186,18 @@ public record XAI : IGenerativeConfig
187186
public double? Temperature { get; set; }
188187
public double? TopP { get; set; }
189188
}
189+
190+
public record ContextualAI : IGenerativeConfig
191+
{
192+
public const string TypeValue = "generative-contextualai";
193+
public string Type => TypeValue;
194+
195+
public string? Model { get; set; }
196+
public double? Temperature { get; set; }
197+
public double? TopP { get; set; }
198+
public long? MaxNewTokens { get; set; }
199+
public string? SystemPrompt { get; set; }
200+
public bool? AvoidCommentary { get; set; }
201+
public string[]? Knowledge { get; set; }
202+
}
190203
}

src/Weaviate.Client/Models/RerankerConfig.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,21 @@ public static class Models
3131
}
3232
}
3333

34+
public record ContextualAI : IRerankerConfig
35+
{
36+
public const string TypeValue = "reranker-contextualai";
37+
public string Type => TypeValue;
38+
39+
public string? Model { get; set; }
40+
public string? Instruction { get; set; }
41+
public int? TopN { get; set; }
42+
}
43+
3444
public record VoyageAI : IRerankerConfig
3545
{
3646
public const string TypeValue = "reranker-voyageai";
3747
public string Type => TypeValue;
3848

39-
public string? BaseURL { get; set; }
4049
public string? Model { get; set; }
4150

4251
public static class Models

src/Weaviate.Client/gRPC/Search.Builders.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,19 @@ private static V1.GenerativeProvider GetGenerativeProvider(Models.GenerativeProv
352352
SetIfNotNull(v => result.Xai.TopP = (float)v, a.TopP);
353353
SetIfNotNull(v => result.Xai.MaxTokens = v, a.MaxTokens);
354354
break;
355+
case Models.Generative.Providers.ContextualAI a:
356+
result.Contextualai = new V1.GenerativeContextualAI
357+
{
358+
Model = a.Model ?? string.Empty,
359+
SystemPrompt = a.SystemPrompt ?? string.Empty,
360+
Knowledge =
361+
a.Knowledge != null ? new V1.TextArray { Values = { a.Knowledge } } : null,
362+
};
363+
SetIfNotNull(v => result.Contextualai.Temperature = (float)v, a.Temperature);
364+
SetIfNotNull(v => result.Contextualai.TopP = (float)v, a.TopP);
365+
SetIfNotNull(v => result.Contextualai.MaxNewTokens = v, a.MaxNewTokens);
366+
SetIfNotNull(v => result.Contextualai.AvoidCommentary = v, a.AvoidCommentary);
367+
break;
355368
default:
356369
throw new NotSupportedException(
357370
$"Unknown generative provider type: {provider.GetType().Name}"

src/Weaviate.Client/gRPC/proto/v1/generative.proto

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ message GenerativeSearch {
1313
string prompt = 1;
1414
bool debug = 2;
1515
// only allow one at the beginning, but multiple in the future
16-
repeated GenerativeProvider queries = 3;
16+
repeated GenerativeProvider queries = 3;
1717
}
18-
18+
1919
message Grouped {
2020
string task = 1;
2121
optional TextArray properties = 2;
@@ -47,6 +47,7 @@ message GenerativeProvider {
4747
GenerativeFriendliAI friendliai = 12;
4848
GenerativeNvidia nvidia = 13;
4949
GenerativeXAI xai = 14;
50+
GenerativeContextualAI contextualai = 15;
5051
}
5152
}
5253

@@ -205,6 +206,16 @@ message GenerativeXAI{
205206
optional TextArray image_properties = 7;
206207
}
207208

209+
message GenerativeContextualAI{
210+
optional string model = 1;
211+
optional double temperature = 2;
212+
optional double top_p = 3;
213+
optional int64 max_new_tokens = 4;
214+
optional string system_prompt = 5;
215+
optional bool avoid_commentary = 6;
216+
optional TextArray knowledge = 7;
217+
}
218+
208219
message GenerativeAnthropicMetadata {
209220
message Usage {
210221
int64 input_tokens = 1;

0 commit comments

Comments
 (0)