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

Restaurant template add serial number #128

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `restaurant_menu_item` add column `serial_number` int null;
3 changes: 3 additions & 0 deletions src/SmartTalk.Core/Domain/Restaurants/RestaurantMenuItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class RestaurantMenuItem : IEntity
[Column("restaurant_id")]
public int RestaurantId { get; set; }

[Column("serial_number")]
public int SerialNumber { get; set; }

[Column("price")]
public decimal Price { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
using SmartTalk.Messages.Dto.AiSpeechAssistant;
using SmartTalk.Messages.Events.AiSpeechAssistant;
using Twilio.TwiML.Voice;
using Twilio.Types;
using Stream = Twilio.TwiML.Voice.Stream;
using Task = System.Threading.Tasks.Task;

namespace SmartTalk.Core.Services.AiSpeechAssistant;
Expand Down Expand Up @@ -322,18 +320,64 @@ private async Task SendToWebSocketAsync(WebSocket socket, object message)

private async Task SendSessionUpdateAsync(WebSocket openAiWebSocket, string prompt)
{
var sessionUpdate = new
var sessionUpdate = new AiSpeechAssistantSessionDto
{
type = "session.update",
session = new
Type = "session.update",
Session = new Session
{
turn_detection = new { type = "server_vad" },
input_audio_format = "g711_ulaw",
output_audio_format = "g711_ulaw",
voice = "alloy",
instructions = prompt,
modalities = new[] { "text", "audio" },
temperature = 0.8
TurnDetection = new TurnDetection { Type = "server_vad" },
InputAudioFormat = "g711_ulaw",
OutputAudioFormat = "g711_ulaw",
Voice = "alloy",
Instructions = prompt,
Modalities = new List<string> { "text", "audio" },
Temperature = 0.8,
ToolChoice = "auto",
Tools = new List<Tool>
{
new Tool
{
Type = "function",
Name = "order",
Description = "When the customer says that's enough, or clearly says he wants to place an order, " +
"the rest are not the final order, but just recording the order.",
Parameters = new ToolParameters
{
Type = "object",
Properties = new ToolProperties
{
OrderedItems = new OrderedItems
{
Type = "array",
Description = "List of items ordered by the customer",
Items = new OrderedItemProperties
{
ItemName = new ItemProperty
{
Type = "string",
Description = "Name of the item ordered"
},
Count = new ItemProperty
{
Type = "number",
Description = "Quantity of the item ordered"
},
Comment = new ItemProperty
{
Type = "string",
Description = "Special requirements or comments regarding the item"
},
SerialNumber = new ItemProperty()
{
Type = "number",
Description = "The serial number of the item ordered"
}
}
}
}
}
}
}
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
namespace SmartTalk.Messages.Dto.AiSpeechAssistant;

public class AiSpeechAssistantSessionDto
{
public string Type { get; set; }

public Session Session { get; set; }
}

public class Session
{
public TurnDetection TurnDetection { get; set; }

public string InputAudioFormat { get; set; }

public string OutputAudioFormat { get; set; }

public string Voice { get; set; }

public string Instructions { get; set; }

public List<string> Modalities { get; set; }

public double Temperature { get; set; }

public string ToolChoice { get; set; }

public List<Tool> Tools { get; set; }
}

public class TurnDetection
{
public string Type { get; set; }
}

public class Tool
{
public string Type { get; set; }

public string Name { get; set; }

public string Description { get; set; }

public ToolParameters Parameters { get; set; }
}

public class ToolParameters
{
public string Type { get; set; }

public ToolProperties Properties { get; set; }
}

public class ToolProperties
{
public OrderedItems OrderedItems { get; set; }
}

public class OrderedItems
{
public string Type { get; set; }

public string Description { get; set; }

public OrderedItemProperties Items { get; set; }
}

public class OrderedItemProperties
{
public ItemProperty ItemName { get; set; }

public ItemProperty Count { get; set; }

public ItemProperty Comment { get; set; }

public ItemProperty SerialNumber { get; set; }
}

public class ItemProperty
{
public string Type { get; set; }

public string Description { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class RestaurantMenuItemDto

public int RestaurantId { get; set; }

public int SerialNumber { get; set; }

public decimal Price { get; set; }

public string Name { get; set; }
Expand Down