fix Create Conversation to Handle Default Project Id ...
This commit is contained in:
@@ -1022,6 +1022,66 @@ namespace xAiApi.Controllers
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an AI Conversation ...
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpPost("Projects/Conversations")]
|
||||
public async Task<ActionResult<XAiConversationDto>> CreateProjectConversation(
|
||||
[FromQuery] Guid? projectId,
|
||||
[FromBody] XAiConversationDto item,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (projectId.IsNull() ||
|
||||
!projectId.HasValue ||
|
||||
item.IsNullOrDefault() ||
|
||||
projectId.Value.IsDefaultGuid())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var userInfo = await GetUserInfo();
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
// Update Required Params ...
|
||||
item.OwnerId = userInfo.UserId;
|
||||
if (!item.IsValidForAddOrUpdate())
|
||||
{
|
||||
XException.InvalidData.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var result = await aiService.CreateConversation(
|
||||
item: item,
|
||||
projectId: projectId,
|
||||
ownerId: userInfo.UserId,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
|
||||
@@ -307,7 +307,7 @@ namespace xAiApi.Interfaces
|
||||
/// <returns></returns>
|
||||
Task<XAiConversationDto> CreateConversation(
|
||||
string ownerId,
|
||||
Guid projectId,
|
||||
Guid? projectId,
|
||||
XAiConversationDto item,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
|
||||
@@ -1072,7 +1072,7 @@ namespace xAiApi.Providers
|
||||
/// <returns></returns>
|
||||
public virtual async Task<XAiConversationDto> CreateConversation(
|
||||
string ownerId,
|
||||
Guid projectId,
|
||||
Guid? projectId,
|
||||
XAiConversationDto item,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
|
||||
Reference in New Issue
Block a user