mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-15 21:21:37 +00:00
Refactored the responses API as well
This commit is contained in:
parent
110932548e
commit
18f8eec82c
@ -119,9 +119,7 @@ public sealed class ProviderOpenAI() : BaseProvider("https://api.openai.com/v1/"
|
|||||||
{
|
{
|
||||||
Model = chatModel.Id,
|
Model = chatModel.Id,
|
||||||
|
|
||||||
// Build the messages:
|
// All messages go into the messages field:
|
||||||
// - First of all the system prompt
|
|
||||||
// - Then none-empty user and AI messages
|
|
||||||
Messages = [systemPrompt, ..messages],
|
Messages = [systemPrompt, ..messages],
|
||||||
|
|
||||||
// Right now, we only support streaming completions:
|
// Right now, we only support streaming completions:
|
||||||
@ -134,27 +132,8 @@ public sealed class ProviderOpenAI() : BaseProvider("https://api.openai.com/v1/"
|
|||||||
{
|
{
|
||||||
Model = chatModel.Id,
|
Model = chatModel.Id,
|
||||||
|
|
||||||
// Build the messages:
|
// All messages go into the input field:
|
||||||
// - First of all the system prompt
|
Input = [systemPrompt, ..messages],
|
||||||
// - Then none-empty user and AI messages
|
|
||||||
Input = [systemPrompt, ..chatThread.Blocks.Where(n => n.ContentType is ContentType.TEXT && !string.IsNullOrWhiteSpace((n.Content as ContentText)?.Text)).Select(n => new TextMessage
|
|
||||||
{
|
|
||||||
Role = n.Role switch
|
|
||||||
{
|
|
||||||
ChatRole.USER => "user",
|
|
||||||
ChatRole.AI => "assistant",
|
|
||||||
ChatRole.AGENT => "assistant",
|
|
||||||
ChatRole.SYSTEM => systemPromptRole,
|
|
||||||
|
|
||||||
_ => "user",
|
|
||||||
},
|
|
||||||
|
|
||||||
Content = n.Content switch
|
|
||||||
{
|
|
||||||
ContentText text => text.Text,
|
|
||||||
_ => string.Empty,
|
|
||||||
}
|
|
||||||
}).ToList()],
|
|
||||||
|
|
||||||
// Right now, we only support streaming completions:
|
// Right now, we only support streaming completions:
|
||||||
Stream = true,
|
Stream = true,
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace AIStudio.Provider.OpenAI;
|
|||||||
/// <param name="Tools">The tools to use for the request.</param>
|
/// <param name="Tools">The tools to use for the request.</param>
|
||||||
public record ResponsesAPIRequest(
|
public record ResponsesAPIRequest(
|
||||||
string Model,
|
string Model,
|
||||||
IList<TextMessage> Input,
|
IList<IMessageBase> Input,
|
||||||
bool Stream,
|
bool Stream,
|
||||||
bool Store,
|
bool Store,
|
||||||
IList<Tool> Tools)
|
IList<Tool> Tools)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user