Skip to content

Commit b192cc2

Browse files
committed
Update demo program
1 parent fefd1c8 commit b192cc2

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

Elastic.SemanticKernel.Playground/Program.cs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
using System.IO;
3+
using System.Linq;
24
using System.Threading.Tasks;
35

46
using Elastic.Clients.Elasticsearch;
@@ -59,23 +61,21 @@ public static async Task Main(string[] args)
5961
// Crate collection and ingest a few demo records.
6062
await vectorStoreCollection.CreateCollectionIfNotExistsAsync();
6163

62-
await vectorStoreCollection.UpsertAsync(new Hotel
63-
{
64-
HotelId = "1",
65-
HotelName = "First Hotel",
66-
Description = "The blue hotel.",
67-
DescriptionEmbedding = await embeddings.GenerateEmbeddingAsync("The blue hotel."),
68-
ReferenceLink = "Global Hotel Database, Entry 1337"
69-
});
70-
71-
await vectorStoreCollection.UpsertAsync(new Hotel
64+
// CSV format: ID;Hotel Name;Description;Reference Link
65+
var hotels = (await File.ReadAllLinesAsync("D:\\elastic\\semantic-kernel-net\\hotels.csv"))
66+
.Select(x => x.Split(';'));
67+
68+
foreach (var hotel in hotels)
7269
{
73-
HotelId = "2",
74-
HotelName = "Second Hotel",
75-
Description = "The green hotel.",
76-
DescriptionEmbedding = await embeddings.GenerateEmbeddingAsync("The green hotel."),
77-
ReferenceLink = "Global Hotel Database, Entry 4242"
78-
});
70+
await vectorStoreCollection.UpsertAsync(new Hotel
71+
{
72+
HotelId = hotel[0],
73+
HotelName = hotel[1],
74+
Description = hotel[2],
75+
DescriptionEmbedding = await embeddings.GenerateEmbeddingAsync(hotel[2]),
76+
ReferenceLink = hotel[3]
77+
});
78+
}
7979

8080
// Invoke the LLM with a template that uses the search plugin to
8181
// 1. get related information to the user query from the vector store
@@ -98,15 +98,14 @@ Include the source of relevant information in the response.
9898
""",
9999
arguments: new KernelArguments
100100
{
101-
{ "question", "What is the name of the hotel that has the same color as grass?" },
101+
{ "question", "Please show me all hotels that have a rooftop bar." },
102102
},
103103
templateFormat: "handlebars",
104104
promptTemplateFactory: new HandlebarsPromptTemplateFactory());
105105

106106
Console.WriteLine(response.ToString());
107107

108-
// > The name of the hotel that has the same color as grass is "Second Hotel."
109-
// > This hotel is described as the green hotel. (Source: Global Hotel Database, Entry 4242)
108+
// > Urban Chic Hotel has a rooftop bar with stunning views (Source: https://example.com/stu654).
110109
}
111110
}
112111

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
1;The Grand Horizon;An upscale hotel offering panoramic city views from every room. Guests can enjoy a luxurious spa, fine dining, and a state-of-the-art fitness center. The hotel is perfect for those looking to experience the best of both relaxation and vibrant city life.;https://example.com/abc123
2+
2;Seaside Retreat;This exclusive beachfront resort is the perfect escape for those seeking tranquility and adventure. With private villas that open directly to the beach, guests can indulge in world-class dining, water sports, and personalized services like spa treatments and guided tours.;https://example.com/xyz789
3+
3;Lakeside Inn;Nestled beside a serene lake, this charming inn offers a peaceful retreat for nature lovers. Guests can enjoy cozy rooms with lake views, as well as scenic walking trails, fishing, and boat rentals. The inn's rustic charm makes it ideal for a relaxing getaway.;https://example.com/lmn456
4+
4;Mountain Peak Lodge;Set in the heart of the mountains, this rustic lodge offers the best in winter sports and outdoor adventures. Ski-in/ski-out access, a cozy fireplace lounge, and guided hikes are just a few of the activities that make this lodge a perfect choice for nature enthusiasts and skiers alike.;https://example.com/pqr321
5+
5;Urban Chic Hotel;A modern boutique hotel located in the center of the city’s vibrant arts and entertainment district. Guests can enjoy contemporary rooms, a rooftop bar with stunning views, and easy access to theaters, galleries, and dining. It's the perfect base for urban explorers and culture seekers.;https://example.com/stu654
6+
6;The Royal Palms Resort;This luxurious five-star resort is set amidst lush tropical gardens and features a world-class spa, gourmet restaurants, and exclusive beach access. With its elegant rooms and personalized service, guests are treated to an unforgettable experience that combines relaxation and opulence.;https://example.com/uvw987
7+
7;Sunset Beach Resort;Overlooking pristine beaches, this exclusive resort offers a range of water activities, including snorkeling, kayaking, and paddleboarding. The all-inclusive packages cater to families and couples alike, ensuring that every guest enjoys both adventure and relaxation by the ocean.;https://example.com/efg852
8+
8;Cityview Suites;Located in the heart of the city, Cityview Suites boasts spacious, stylish rooms with breathtaking views of the skyline. Guests can enjoy top-notch amenities such as a 24-hour concierge, a rooftop pool, and easy access to the city's best shopping and dining destinations.;https://example.com/hij753
9+
9;Countryside Manor;This elegant country manor offers a peaceful escape with beautifully landscaped gardens and luxurious accommodations. Guests can unwind with afternoon tea, explore the expansive grounds, or visit nearby vineyards, making it the perfect place for a romantic getaway or a quiet retreat.;https://example.com/klm258
10+
10;The Vintage Retreat;Set in a beautifully restored historical building, The Vintage Retreat blends classic charm with modern amenities. Guests can enjoy beautifully appointed rooms, gourmet dining, and a peaceful garden. It's an ideal location for those seeking a relaxing stay in an intimate, quiet atmosphere.;https://example.com/vwx147

0 commit comments

Comments
 (0)