mirror of
https://github.com/Shchoholiev/shopping-assistant-api.git
synced 2025-04-12 01:48:49 +00:00
SA-29 added models and interface
This commit is contained in:
parent
9b0410fb1f
commit
bdc3e658cc
13
ShoppingAssistantApi.Application/IServices/IOpenAiService.cs
Normal file
13
ShoppingAssistantApi.Application/IServices/IOpenAiService.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using ShoppingAssistantApi.Application.Models.OpenAi;
|
||||||
|
|
||||||
|
namespace ShoppingAssistantApi.Application.IServices;
|
||||||
|
|
||||||
|
public interface IOpenAiService
|
||||||
|
{
|
||||||
|
Task<OpenAiMessage> GetChatCompletion(ChatCompletionRequest chat, CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves a stream of tokens (pieces of words) based on provided chat.
|
||||||
|
/// </summary>
|
||||||
|
IAsyncEnumerable<string> GetChatCompletionStream(ChatCompletionRequest chat, CancellationToken cancellationToken);
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
namespace ShoppingAssistantApi.Application.Models.OpenAi;
|
||||||
|
|
||||||
|
public class ChatCompletionRequest
|
||||||
|
{
|
||||||
|
public string Model { get; set; } = "gpt-3.5-turbo";
|
||||||
|
|
||||||
|
public List<OpenAiMessage> Messages { get; set; }
|
||||||
|
|
||||||
|
public double Temperature { get; set; } = 0.7;
|
||||||
|
|
||||||
|
public int MaxTokens { get; set; } = 256;
|
||||||
|
|
||||||
|
public bool Stream { get; set; } = false;
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
using ShoppingAssistantApi.Domain.Enums;
|
||||||
|
|
||||||
|
namespace ShoppingAssistantApi.Application.Models.OpenAi;
|
||||||
|
|
||||||
|
public class OpenAiMessage
|
||||||
|
{
|
||||||
|
public OpenAiRole Role { get; set; }
|
||||||
|
|
||||||
|
public string Content { get; set; }
|
||||||
|
}
|
8
ShoppingAssistantApi.Domain/Enums/OpenAiRole.cs
Normal file
8
ShoppingAssistantApi.Domain/Enums/OpenAiRole.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace ShoppingAssistantApi.Domain.Enums;
|
||||||
|
|
||||||
|
public enum OpenAiRole
|
||||||
|
{
|
||||||
|
System,
|
||||||
|
User,
|
||||||
|
Assistant
|
||||||
|
}
|
@ -1,11 +1,24 @@
|
|||||||
using System;
|
using ShoppingAssistantApi.Application.IServices;
|
||||||
using System.Collections.Generic;
|
using ShoppingAssistantApi.Application.Models.OpenAi;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ShoppingAssistantApi.Infrastructure.Services;
|
namespace ShoppingAssistantApi.Infrastructure.Services;
|
||||||
|
|
||||||
public class OpenAiService
|
public class OpenAiService : IOpenAiService
|
||||||
{
|
{
|
||||||
|
private readonly HttpClient _httpClient;
|
||||||
|
|
||||||
|
public OpenAiService(HttpClient client)
|
||||||
|
{
|
||||||
|
_httpClient = client;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<OpenAiMessage> GetChatCompletion(ChatCompletionRequest chat, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IAsyncEnumerable<string> GetChatCompletionStream(ChatCompletionRequest chat, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user