Skip to content

Commit

Permalink
Merge pull request #1243 from solliancenet/cp_core_api_updates
Browse files Browse the repository at this point in the history
Core API work
  • Loading branch information
ciprianjichici authored Jul 18, 2024
2 parents d9695c8 + 4a3b24f commit 6ae0e01
Show file tree
Hide file tree
Showing 26 changed files with 221 additions and 187 deletions.
15 changes: 9 additions & 6 deletions docs/release-notes/breaking-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@

Core API changes:

1. The `/orchestration/*` endpoints have been moved to `/completions/*`.
1. The previous `/orchestration/completions` endpoint is now `/completions`.
2. The `/sessions/{sessionId}/completion` endpoint has been moved to `/completions`. Instead of having the `sessionId` as a path parameter, it is now in the request body as part of the `CompletionRequest` payload.
3. `/sessions/{sessionId}/summarize-name` has been removed. In the future, the `/completions` endpoint will be used to generate summaries.
4. `OrchestrationRequest` and `CompletionRequest` have combined into a single `CompletionRequest` object.
5. `DirectionCompletionRequest` has been removed. Use `CompletionRequest` instead.
1. All Core API endpoints have been moved to the `/instances/{instanceId}` path. For example, the `/status` endpoint is now `/instances/{instanceId}/status`.

2. The `/orchestration/*` endpoints have been moved to `/instances/{instanceId}/completions/*`.
1. The previous `/orchestration/completions` endpoint is now `/instances/{instanceId}/completions`.
3. The `/sessions/{sessionId}/completion` endpoint has been moved to `/instances/{instanceId}/completions`. Instead of having the `sessionId` as a path parameter, it is now in the request body as part of the `CompletionRequest` payload.
4. `/sessions/{sessionId}/summarize-name` has been removed. In the future, the `/completions` endpoint will be used to generate summaries.
5. `OrchestrationRequest` and `CompletionRequest` have combined into a single `CompletionRequest` object.
6. `DirectionCompletionRequest` has been removed. Use `CompletionRequest` instead.
7. `Status` controllers `\status` action in the .NET API projects return value has renamed the `Instance` property to `InstanceName`.

### Pre-0.8.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public IActionResult GetServiceStatus() =>
new OkObjectResult(new ServiceStatusInfo
{
Name = ServiceNames.AuthorizationAPI,
Instance = ValidatedEnvironment.MachineName,
InstanceName = ValidatedEnvironment.MachineName,
Version = Environment.GetEnvironmentVariable(EnvironmentVariables.FoundationaLLM_Version),
Status = ServiceStatuses.Ready
});
Expand Down
17 changes: 14 additions & 3 deletions src/dotnet/Common/Models/Infrastructure/ServiceStatusInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,38 @@ public class ServiceStatusInfo
/// The name of the service.
/// </summary>
[JsonPropertyName("name")]
public string? Name { get; set; }
public required string Name { get; set; }

/// <summary>
/// The instance ID of the service.
/// </summary>
[JsonPropertyName("instance_id")]
public string? InstanceId { get; set; }

/// <summary>
/// The instance of the service.
/// </summary>
[JsonPropertyName("instance")]
public string? Instance { get; set; }
[JsonPropertyName("instance_name")]
public string? InstanceName { get; set; }

/// <summary>
/// The deployed FoundationaLLM version of the service.
/// </summary>
[JsonPropertyName("version")]
public string? Version { get; set; }

/// <summary>
/// The status of the service.
/// </summary>
[JsonPropertyName("status")]
public string? Status { get; set; }

/// <summary>
/// The message associated with the status.
/// </summary>
[JsonPropertyName("message")]
public string? Message { get; set; }

/// <summary>
/// The status of all the subordinate services.
/// </summary>
Expand Down
41 changes: 31 additions & 10 deletions src/dotnet/Core/Interfaces/ICoreService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,75 @@ public interface ICoreService
/// <summary>
/// Returns list of chat session ids and names.
/// </summary>
Task<List<Session>> GetAllChatSessionsAsync();
/// <param name="instanceId">The instance id for which to retrieve chat sessions.</param>
Task<List<Session>> GetAllChatSessionsAsync(string instanceId);

/// <summary>
/// Returns the chat messages related to an existing session.
/// </summary>
Task<List<Message>> GetChatSessionMessagesAsync(string sessionId);
/// <param name="instanceId">The instance id for which to retrieve chat messages.</param>
/// <param name="sessionId">The session id for which to retrieve chat messages.</param>
Task<List<Message>> GetChatSessionMessagesAsync(string instanceId, string sessionId);

/// <summary>
/// Creates a new chat session.
/// </summary>
Task<Session> CreateNewChatSessionAsync();
/// <param name="instanceId">The instance Id.</param>
Task<Session> CreateNewChatSessionAsync(string instanceId);

/// <summary>
/// Rename the chat session from its default (eg., "New Chat") to the summary provided by OpenAI.
/// </summary>
Task<Session> RenameChatSessionAsync(string sessionId, string newChatSessionName);
/// <param name="instanceId">The instance id.</param>
/// <param name="sessionId">The session id to rename.</param>
/// <param name="newChatSessionName">The new name for the chat session.</param>
Task<Session> RenameChatSessionAsync(string instanceId, string sessionId, string newChatSessionName);

/// <summary>
/// Delete a chat session and related messages.
/// </summary>
Task DeleteChatSessionAsync(string sessionId);
/// <param name="instanceId">The instance id.</param>
/// <param name="sessionId">The session id to delete.</param>
Task DeleteChatSessionAsync(string instanceId, string sessionId);

/// <summary>
/// Receive a prompt from a user, retrieve the message history from the related session,
/// generate a completion response, and log full completion results.
/// </summary>
Task<Completion> GetChatCompletionAsync(CompletionRequest completionRequest);
/// <param name="instanceId">The instance id.</param>
/// <param name="completionRequest">The completion request.</param>
Task<Completion> GetChatCompletionAsync(string instanceId, CompletionRequest completionRequest);

/// <summary>
/// Provides a completion for a user prompt, without a session.
/// </summary>
Task<Completion> GetCompletionAsync(CompletionRequest directCompletionRequest);
/// <param name="instanceId">The instance id.</param>
/// <param name="directCompletionRequest">The completion request.</param>
Task<Completion> GetCompletionAsync(string instanceId, CompletionRequest directCompletionRequest);

/// <summary>
/// Generate a name for a chat message, based on the passed in prompt.
/// </summary>
Task<Completion> SummarizeChatSessionNameAsync(string? sessionId, string prompt);
/// <param name="instanceId">The instance id.</param>
/// <param name="sessionId">The session id to rename.</param>
/// <param name="text">The text to use when generating the name.</param>
Task<Completion> GenerateChatSessionNameAsync(string instanceId, string? sessionId, string? text);

/// <summary>
/// Rate an assistant message. This can be used to discover useful AI responses for training, discoverability, and other benefits down the road.
/// </summary>
Task<Message> RateMessageAsync(string id, string sessionId, bool? rating);
/// <param name="instanceId">The instance id.</param>
/// <param name="id">The message id to rate.</param>
/// <param name="sessionId">The session id to which the message belongs.</param>
/// <param name="rating">The rating to assign to the message.</param>
Task<Message> RateMessageAsync(string instanceId, string id, string sessionId, bool? rating);

/// <summary>
/// Returns the completion prompt for a given session and completion prompt id.
/// </summary>
/// <param name="instanceId">The instance Id.</param>
/// <param name="sessionId">The session id from which to retrieve the completion prompt.</param>
/// <param name="completionPromptId">The id of the completion prompt to retrieve.</param>
/// <returns></returns>
Task<CompletionPrompt> GetCompletionPrompt(string sessionId, string completionPromptId);
Task<CompletionPrompt> GetCompletionPrompt(string instanceId, string sessionId, string completionPromptId);
}
9 changes: 6 additions & 3 deletions src/dotnet/Core/Interfaces/IUserProfileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,26 @@ public interface IUserProfileService
/// <summary>
/// Returns the user profile of the signed in user.
/// </summary>
/// <param name="instanceId">The instance ID.</param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
Task<UserProfile?> GetUserProfileAsync();
Task<UserProfile?> GetUserProfileAsync(string instanceId);

/// <summary>
/// Returns the user profile of the specified user.
/// </summary>
/// <param name="instanceId">The instance ID.</param>
/// <param name="upn">The user principal name of the user for whom to return the user profile.</param>
/// <returns></returns>
Task<UserProfile?> GetUserProfileForUserAsync(string upn);
Task<UserProfile?> GetUserProfileForUserAsync(string instanceId, string upn);

/// <summary>
/// Inserts or updates a user profile.
/// </summary>
/// <param name="instanceId">The instance ID.</param>
/// <param name="userProfile">The user profile to upsert.</param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
Task UpsertUserProfileAsync(UserProfile userProfile);
Task UpsertUserProfileAsync(string instanceId, UserProfile userProfile);
}
}
Loading

0 comments on commit 6ae0e01

Please sign in to comment.