Skip to content

Commit 85dc263

Browse files
committed
fix: Updated to latest version.
1 parent a92efbe commit 85dc263

File tree

799 files changed

+46150
-6305
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

799 files changed

+46150
-6305
lines changed

OpenAI.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
3636
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
3737
.github\workflows\pull-request.yml = .github\workflows\pull-request.yml
3838
.github\dependabot.yml = .github\dependabot.yml
39-
.github\workflows\auto-remove-branches.yml = .github\workflows\auto-remove-branches.yml
4039
.github\workflows\mkdocs.yml = .github\workflows\mkdocs.yml
4140
EndProjectSection
4241
EndProject

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ Examples and documentation can be found here: https://tryagi.github.io/OpenAI/
2525
using var api = new OpenAiApi("API_KEY");
2626
string response = await api.Chat.CreateChatCompletionAsync(
2727
messages: ["Generate five random words."],
28-
model: CreateChatCompletionRequestModel.Gpt4oMini);
28+
model: ModelIdsSharedEnum.Gpt4oMini);
2929
Console.WriteLine(response); // "apple, banana, cherry, date, elderberry"
3030
3131
var enumerable = api.Chat.CreateChatCompletionAsStreamAsync(
3232
messages: ["Generate five random words."],
33-
model: CreateChatCompletionRequestModel.Gpt4oMini);
33+
model: ModelIdsSharedEnum.Gpt4oMini);
3434

3535
await foreach (string response in enumerable)
3636
{
@@ -97,7 +97,7 @@ var messages = new List<ChatCompletionRequestMessage>
9797
"You are a helpful weather assistant.".AsSystemMessage(),
9898
"What is the current temperature in Dubai, UAE in Celsius?".AsUserMessage(),
9999
};
100-
var model = CreateChatCompletionRequestModel.Gpt4oMini;
100+
var model = ModelIdsSharedEnum.Gpt4oMini;
101101
var result = await api.Chat.CreateChatCompletionAsync(
102102
messages,
103103
model: model,
@@ -142,7 +142,7 @@ using var api = new OpenAiApi("API_KEY");
142142

143143
var response = await api.Chat.CreateChatCompletionAsAsync<Weather>(
144144
messages: ["Generate random weather."],
145-
model: CreateChatCompletionRequestModel.Gpt4oMini,
145+
model: ModelIdsSharedEnum.Gpt4oMini,
146146
jsonSerializerOptions: new JsonSerializerOptions
147147
{
148148
Converters = {new JsonStringEnumConverter()},
@@ -151,7 +151,7 @@ var response = await api.Chat.CreateChatCompletionAsAsync<Weather>(
151151
var response = await api.Chat.CreateChatCompletionAsAsync(
152152
jsonTypeInfo: SourceGeneratedContext.Default.Weather,
153153
messages: ["Generate random weather."],
154-
model: CreateChatCompletionRequestModel.Gpt4oMini);
154+
model: ModelIdsSharedEnum.Gpt4oMini);
155155

156156
// response.Value1 contains the structured output
157157
// response.Value2 contains the CreateChatCompletionResponse object
@@ -202,10 +202,10 @@ There also non-try methods that throw an exception if the value is not found.
202202
using OpenAI;
203203

204204
// You can try to get the enum from string using:
205-
var model = CreateChatCompletionRequestModelExtensions.ToEnum("gpt-4o") ?? throw new Exception("Invalid model");
205+
var model = ModelIdsSharedEnumExtensions.ToEnum("gpt-4o") ?? throw new Exception("Invalid model");
206206

207207
// Chat
208-
var model = CreateChatCompletionRequestModel.Gpt4oMini;
208+
var model = ModelIdsSharedEnum.Gpt4oMini;
209209
double? priceInUsd = model.TryGetPriceInUsd(
210210
inputTokens: 500,
211211
outputTokens: 500)

src/libs/tryAGI.OpenAI/ChatClient.LatestModelConstants.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ public partial class ChatClient
55
/// <summary>
66
/// Always points to the latest smart model.
77
/// </summary>
8-
public const ModelIdsEnum LatestSmartModel = ModelIdsEnum.Gpt4o;
8+
public const ModelIdsSharedEnum LatestSmartModel = ModelIdsSharedEnum.Gpt41;
99

1010
/// <summary>
1111
/// Always points to the latest fast model.
1212
/// </summary>
13-
public const ModelIdsEnum LatestFastModel = ModelIdsEnum.Gpt4oMini;
13+
public const ModelIdsSharedEnum LatestFastModel = ModelIdsSharedEnum.Gpt41Mini;
1414

1515
/// <summary>
1616
/// Always points to the latest smart reasoning model.
1717
/// </summary>
18-
public const ModelIdsEnum LatestSmartReasoningModel = ModelIdsEnum.O1Preview;
18+
public const ModelIdsSharedEnum LatestSmartReasoningModel = ModelIdsSharedEnum.O3;
1919

2020
/// <summary>
2121
/// Always points to the latest fast reasoning model.
2222
/// </summary>
23-
public const ModelIdsEnum LatestFastReasoningModel = ModelIdsEnum.O1Mini;
23+
public const ModelIdsSharedEnum LatestFastReasoningModel = ModelIdsSharedEnum.O4Mini;
2424
}

src/libs/tryAGI.OpenAI/Conversions/ChatCompletionRequestUserMessageContentPart.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ namespace tryAGI.OpenAI;
22

33
public partial struct ChatCompletionRequestUserMessageContentPart
44
{
5-
/// <inheritdoc />
6-
public override string ToString()
7-
{
8-
return IsText
9-
? Text?.Text ?? string.Empty
10-
: IsImage
11-
? Image?.ImageUrl.Url ?? string.Empty
12-
: string.Empty;
13-
}
5+
// /// <inheritdoc />
6+
// public override string ToString()
7+
// {
8+
// return IsText
9+
// ? Text?.Text ?? string.Empty
10+
// : IsImage
11+
// ? Image?.ImageUrl.Url ?? string.Empty
12+
// : string.Empty;
13+
// }
1414

1515
/// <summary>
1616
///
@@ -20,7 +20,7 @@ public override string ToString()
2020
public static implicit operator string(ChatCompletionRequestUserMessageContentPart response)
2121
{
2222
#pragma warning disable CA1062
23-
return response.ToString();
23+
return response.ToString() ?? string.Empty;
2424
#pragma warning restore CA1062
2525
}
2626

src/libs/tryAGI.OpenAI/Conversions/CreateMessageRequest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public static CreateMessageRequest FromOpenAIFile(
4949
return new CreateMessageRequest
5050
{
5151
Role = role,
52-
Content = new List<ContentVariant2Item>
53-
{
54-
MessageContentImageFileObject.FromOpenAIFile(file, detail),
55-
},
52+
Content = new List<global::tryAGI.OpenAI.OneOf<global::tryAGI.OpenAI.MessageContentImageFileObject, global::tryAGI.OpenAI.MessageContentImageUrlObject, global::tryAGI.OpenAI.MessageRequestContentTextObject>>
53+
{
54+
MessageContentImageFileObject.FromOpenAIFile(file, detail),
55+
},
5656
};
5757
}
5858

@@ -90,7 +90,7 @@ public static CreateMessageRequest FromUri(
9090
return new CreateMessageRequest
9191
{
9292
Role = role,
93-
Content = new List<ContentVariant2Item>
93+
Content = new List<global::tryAGI.OpenAI.OneOf<global::tryAGI.OpenAI.MessageContentImageFileObject, global::tryAGI.OpenAI.MessageContentImageUrlObject, global::tryAGI.OpenAI.MessageRequestContentTextObject>>
9494
{
9595
MessageContentImageUrlObject.FromUri(uri, detail),
9696
},

0 commit comments

Comments
 (0)