first commit
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
package dto
|
||||
|
||||
import "browser.local/platform/domain"
|
||||
|
||||
type AIInvocationRequest struct {
|
||||
RequestID string `json:"requestId"`
|
||||
PluginID string `json:"pluginId,omitempty"`
|
||||
RouteKey string `json:"routeKey,omitempty"`
|
||||
ServerInstanceID string `json:"serverInstanceId,omitempty"`
|
||||
Purpose string `json:"purpose"`
|
||||
ProviderID string `json:"providerId,omitempty"`
|
||||
Model string `json:"model,omitempty"`
|
||||
Prompt string `json:"prompt"`
|
||||
CurrentConfig string `json:"currentConfig,omitempty"`
|
||||
ContextRefs map[string]string `json:"contextRefs,omitempty"`
|
||||
}
|
||||
|
||||
type LlmConfigSuggestionRequest struct {
|
||||
ServerInstanceID string `json:"serverInstanceId"`
|
||||
Prompt string `json:"prompt"`
|
||||
CurrentConfig string `json:"currentConfig"`
|
||||
}
|
||||
|
||||
type LlmConfigSuggestionResponse struct {
|
||||
ServerInstanceID string `json:"serverInstanceId"`
|
||||
Recommendation string `json:"recommendation"`
|
||||
SuggestedConfig string `json:"suggestedConfig,omitempty"`
|
||||
}
|
||||
|
||||
type AIInvocationUsageResponse struct {
|
||||
ProviderID string `json:"providerId"`
|
||||
Model string `json:"model"`
|
||||
InputTokens int `json:"inputTokens"`
|
||||
OutputTokens int `json:"outputTokens"`
|
||||
Mocked bool `json:"mocked"`
|
||||
}
|
||||
|
||||
type AIConfigRecommendationResponse struct {
|
||||
Key string `json:"key"`
|
||||
SuggestedConfig string `json:"suggestedConfig,omitempty"`
|
||||
DiffSummary string `json:"diffSummary"`
|
||||
}
|
||||
|
||||
type AIInvocationSafeErrorResponse struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Details []string `json:"details,omitempty"`
|
||||
}
|
||||
|
||||
type AIInvocationResponse struct {
|
||||
RequestID string `json:"requestId"`
|
||||
Purpose string `json:"purpose"`
|
||||
ProviderID string `json:"providerId,omitempty"`
|
||||
Model string `json:"model,omitempty"`
|
||||
Status string `json:"status"`
|
||||
Recommendation string `json:"recommendation,omitempty"`
|
||||
ConfigRecommendation *AIConfigRecommendationResponse `json:"configRecommendation,omitempty"`
|
||||
Usage AIInvocationUsageResponse `json:"usage"`
|
||||
Error *AIInvocationSafeErrorResponse `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
func (request AIInvocationRequest) ToDomain() domain.AIInvocationRequest {
|
||||
return domain.AIInvocationRequest{
|
||||
RequestID: request.RequestID,
|
||||
PluginID: request.PluginID,
|
||||
RouteKey: request.RouteKey,
|
||||
ServerInstanceID: request.ServerInstanceID,
|
||||
Purpose: request.Purpose,
|
||||
ProviderID: request.ProviderID,
|
||||
Model: request.Model,
|
||||
Prompt: request.Prompt,
|
||||
CurrentConfig: request.CurrentConfig,
|
||||
ContextRefs: domain.CopyStringMap(request.ContextRefs),
|
||||
}
|
||||
}
|
||||
|
||||
func AIInvocationFromDomain(response domain.AIInvocationResponse) AIInvocationResponse {
|
||||
response = domain.CopyAIInvocationResponse(response)
|
||||
var config *AIConfigRecommendationResponse
|
||||
if response.ConfigRecommendation != nil {
|
||||
config = &AIConfigRecommendationResponse{
|
||||
Key: response.ConfigRecommendation.Key,
|
||||
SuggestedConfig: response.ConfigRecommendation.SuggestedConfig,
|
||||
DiffSummary: response.ConfigRecommendation.DiffSummary,
|
||||
}
|
||||
}
|
||||
var safeError *AIInvocationSafeErrorResponse
|
||||
if response.Error != nil {
|
||||
safeError = &AIInvocationSafeErrorResponse{Code: response.Error.Code, Message: response.Error.Message, Details: response.Error.Details}
|
||||
}
|
||||
return AIInvocationResponse{
|
||||
RequestID: response.RequestID,
|
||||
Purpose: response.Purpose,
|
||||
ProviderID: response.ProviderID,
|
||||
Model: response.Model,
|
||||
Status: response.Status,
|
||||
Recommendation: response.Recommendation,
|
||||
ConfigRecommendation: config,
|
||||
Usage: AIInvocationUsageResponse{
|
||||
ProviderID: response.Usage.ProviderID,
|
||||
Model: response.Usage.Model,
|
||||
InputTokens: response.Usage.InputTokens,
|
||||
OutputTokens: response.Usage.OutputTokens,
|
||||
Mocked: response.Usage.Mocked,
|
||||
},
|
||||
Error: safeError,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user