diff --git a/src/dotnet/Core/Interfaces/ICoreService.cs b/src/dotnet/Core/Interfaces/ICoreService.cs
index 781bd4a8ca..c7042cc6a5 100644
--- a/src/dotnet/Core/Interfaces/ICoreService.cs
+++ b/src/dotnet/Core/Interfaces/ICoreService.cs
@@ -26,16 +26,16 @@ public interface ICoreService
/// Creates a new chat session.
///
/// The instance Id.
- /// The name for the chat session.
- Task CreateNewChatSessionAsync(string instanceId, string chatSessionName);
+ /// The name for the chat session.
+ Task CreateNewChatSessionAsync(string instanceId, string sessionName);
///
/// Rename the chat session from its default (eg., "New Chat") to the summary provided by OpenAI.
///
/// The instance id.
/// The session id to rename.
- /// The new name for the chat session.
- Task RenameChatSessionAsync(string instanceId, string sessionId, string newChatSessionName);
+ /// The new name for the chat session.
+ Task RenameChatSessionAsync(string instanceId, string sessionId, string sessionName);
///
/// Delete a chat session and related messages.
diff --git a/src/dotnet/Core/Interfaces/ICosmosDbService.cs b/src/dotnet/Core/Interfaces/ICosmosDbService.cs
index fb0ce9f8b7..5f4bc81674 100644
--- a/src/dotnet/Core/Interfaces/ICosmosDbService.cs
+++ b/src/dotnet/Core/Interfaces/ICosmosDbService.cs
@@ -80,10 +80,10 @@ public interface ICosmosDbService
/// Updates a session's name through a patch operation.
///
/// The session id.
- /// The session's new name.
+ /// The session's new name.
/// Cancellation token for async calls.
/// Revised chat session item.
- Task UpdateSessionNameAsync(string id, string name, CancellationToken cancellationToken = default);
+ Task UpdateSessionNameAsync(string id, string sessionName, CancellationToken cancellationToken = default);
///
/// Batch create or update chat messages and session.
diff --git a/src/dotnet/Core/Services/CoreService.cs b/src/dotnet/Core/Services/CoreService.cs
index 8b0eb97ba4..35a1b9be58 100644
--- a/src/dotnet/Core/Services/CoreService.cs
+++ b/src/dotnet/Core/Services/CoreService.cs
@@ -1,4 +1,3 @@
-using Azure.Core;
using FoundationaLLM.Common.Constants;
using FoundationaLLM.Common.Constants.ResourceProviders;
using FoundationaLLM.Common.Exceptions;
@@ -66,13 +65,13 @@ public async Task> GetChatSessionMessagesAsync(string instanceId,
}
///
- public async Task CreateNewChatSessionAsync(string instanceId, string chatSessionName)
+ public async Task CreateNewChatSessionAsync(string instanceId, string sessionName)
{
- ArgumentException.ThrowIfNullOrEmpty(chatSessionName);
+ ArgumentException.ThrowIfNullOrEmpty(sessionName);
Session session = new()
{
- Name = chatSessionName,
+ Name = sessionName,
Type = _sessionType,
UPN = _callContext.CurrentUserIdentity?.UPN ?? throw new InvalidOperationException("Failed to retrieve the identity of the signed in user when creating a new chat session.")
};
@@ -80,12 +79,12 @@ public async Task CreateNewChatSessionAsync(string instanceId, string c
}
///
- public async Task RenameChatSessionAsync(string instanceId, string sessionId, string newChatSessionName)
+ public async Task RenameChatSessionAsync(string instanceId, string sessionId, string sessionName)
{
ArgumentNullException.ThrowIfNull(sessionId);
- ArgumentException.ThrowIfNullOrEmpty(newChatSessionName);
+ ArgumentException.ThrowIfNullOrEmpty(sessionName);
- return await _cosmosDbService.UpdateSessionNameAsync(sessionId, newChatSessionName);
+ return await _cosmosDbService.UpdateSessionNameAsync(sessionId, sessionName);
}
///
diff --git a/src/dotnet/Core/Services/CosmosDbService.cs b/src/dotnet/Core/Services/CosmosDbService.cs
index 9f42477849..7d9fce832c 100644
--- a/src/dotnet/Core/Services/CosmosDbService.cs
+++ b/src/dotnet/Core/Services/CosmosDbService.cs
@@ -223,14 +223,14 @@ public async Task UpdateSessionAsync(Session session, CancellationToken
}
///
- public async Task UpdateSessionNameAsync(string id, string name, CancellationToken cancellationToken = default)
+ public async Task UpdateSessionNameAsync(string id, string sessionName, CancellationToken cancellationToken = default)
{
var response = await _sessions.PatchItemAsync(
id: id,
partitionKey: new PartitionKey(id),
patchOperations: new[]
{
- PatchOperation.Set("/name", name),
+ PatchOperation.Set("/name", sessionName),
},
cancellationToken: cancellationToken
);
diff --git a/src/dotnet/CoreAPI/Controllers/SessionsController.cs b/src/dotnet/CoreAPI/Controllers/SessionsController.cs
index faa0c35580..b8604819b5 100644
--- a/src/dotnet/CoreAPI/Controllers/SessionsController.cs
+++ b/src/dotnet/CoreAPI/Controllers/SessionsController.cs
@@ -68,20 +68,20 @@ public async Task GetCompletionPrompt(string instanceId, strin
/// Creates a new chat session.
///
/// The id of the instance.
- /// The name for the chat session.
+ /// The name for the chat session.
[HttpPost(Name = "CreateNewChatSession")]
- public async Task CreateNewChatSession(string instanceId, string chatSessionName) =>
- await _coreService.CreateNewChatSessionAsync(instanceId, chatSessionName);
+ public async Task CreateNewChatSession(string instanceId, [FromBody] string sessionName) =>
+ await _coreService.CreateNewChatSessionAsync(instanceId, sessionName);
///
/// Rename the chat session.
///
/// The id of the instance.
/// The id of the session to rename.
- /// The new name for the session.
+ /// The new name for the session.
[HttpPost("{sessionId}/rename", Name = "RenameChatSession")]
- public async Task RenameChatSession(string instanceId, string sessionId, string newChatSessionName) =>
- await _coreService.RenameChatSessionAsync(instanceId, sessionId, newChatSessionName);
+ public async Task RenameChatSession(string instanceId, string sessionId, [FromBody] string sessionName) =>
+ await _coreService.RenameChatSessionAsync(instanceId, sessionId, sessionName);
///
/// Delete a chat session and related messages.
diff --git a/src/dotnet/CoreClient/Clients/RESTClients/SessionRESTClient.cs b/src/dotnet/CoreClient/Clients/RESTClients/SessionRESTClient.cs
index 7b7298799a..5cf7b0344a 100644
--- a/src/dotnet/CoreClient/Clients/RESTClients/SessionRESTClient.cs
+++ b/src/dotnet/CoreClient/Clients/RESTClients/SessionRESTClient.cs
@@ -1,7 +1,7 @@
using Azure.Core;
using FoundationaLLM.Client.Core.Interfaces;
using FoundationaLLM.Common.Models.Chat;
-using System.Text.Encodings.Web;
+using System.Net.Http.Json;
using System.Text.Json;
namespace FoundationaLLM.Client.Core.Clients.RESTClients
@@ -17,10 +17,12 @@ internal class SessionRESTClient(
private readonly string _instanceId = instanceId ?? throw new ArgumentNullException(nameof(instanceId));
///
- public async Task CreateSessionAsync(string chatSessionName)
+ public async Task CreateSessionAsync(string sessionName)
{
var coreClient = await GetCoreClientAsync();
- var responseSession = await coreClient.PostAsync($"instances/{_instanceId}/sessions?chatSessionName={chatSessionName}", null);
+ var responseSession = await coreClient.PostAsync(
+ $"instances/{_instanceId}/sessions",
+ JsonContent.Create(sessionName));
if (responseSession.IsSuccessStatusCode)
{
@@ -39,7 +41,9 @@ public async Task CreateSessionAsync(string chatSessionName)
public async Task RenameChatSession(string sessionId, string sessionName)
{
var coreClient = await GetCoreClientAsync();
- var response = await coreClient.PostAsync($"instances/{_instanceId}/sessions/{sessionId}/rename?newChatSessionName={UrlEncoder.Default.Encode(sessionName)}", null);
+ var response = await coreClient.PostAsync(
+ $"instances/{_instanceId}/sessions/{sessionId}/rename",
+ JsonContent.Create(sessionName));
if (response.IsSuccessStatusCode)
{
diff --git a/src/dotnet/CoreClient/Interfaces/ISessionRESTClient.cs b/src/dotnet/CoreClient/Interfaces/ISessionRESTClient.cs
index 8f6acd8622..ec1763326a 100644
--- a/src/dotnet/CoreClient/Interfaces/ISessionRESTClient.cs
+++ b/src/dotnet/CoreClient/Interfaces/ISessionRESTClient.cs
@@ -25,9 +25,9 @@ public interface ISessionRESTClient
///
/// Creates a new session with the specified name.
///
- /// The name for the chat session.
+ /// The name for the chat session.
/// Returns the new Session ID.
- Task CreateSessionAsync(string chatSessionName);
+ Task CreateSessionAsync(string sessionName);
///
/// Renames a chat session.
diff --git a/tests/dotnet/Core.Tests/Services/CoreServiceTests.cs b/tests/dotnet/Core.Tests/Services/CoreServiceTests.cs
index 53c1acbf0b..d361f5a003 100644
--- a/tests/dotnet/Core.Tests/Services/CoreServiceTests.cs
+++ b/tests/dotnet/Core.Tests/Services/CoreServiceTests.cs
@@ -123,8 +123,8 @@ public async Task CreateNewChatSessionAsync_ShouldReturnANewChatSession()
// Arrange
var currentUserUPN = "testuser@example.com";
var sessionType = "Test_type";
- var chatSessionName = "Test_name";
- var newSession = new Session { Name = chatSessionName, Type = sessionType, UPN = currentUserUPN };
+ var sessionName = "Test_name";
+ var newSession = new Session { Name = sessionName, Type = sessionType, UPN = currentUserUPN };
// Set up mock returns
_callContext.CurrentUserIdentity.Returns(new UnifiedUserIdentity { UPN = currentUserUPN });
@@ -133,13 +133,13 @@ public async Task CreateNewChatSessionAsync_ShouldReturnANewChatSession()
.Returns(Task.FromResult(newSession));
// Act
- var resultSession = await _testedService.CreateNewChatSessionAsync(_instanceId, chatSessionName);
+ var resultSession = await _testedService.CreateNewChatSessionAsync(_instanceId, sessionName);
// Assert
Assert.NotNull(resultSession);
Assert.Equal(sessionType, resultSession.Type);
Assert.Equal(currentUserUPN, resultSession.UPN);
- Assert.Equal(chatSessionName, resultSession.Name);
+ Assert.Equal(sessionName, resultSession.Name);
}
#endregion
@@ -176,12 +176,12 @@ public async Task RenameChatSessionAsync_ShouldReturnTheRenamedChatSession()
public async Task RenameChatSessionAsync_ShouldThrowExceptionWhenSessionIdIsNull()
{
// Arrange
- var newChatSessionName = "NewName";
+ var sessionName = "NewName";
// Assert
await Assert.ThrowsAsync(async () =>
{
- await _testedService.RenameChatSessionAsync(_instanceId, null!, newChatSessionName);
+ await _testedService.RenameChatSessionAsync(_instanceId, null!, sessionName);
});
}