Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
683 changes: 622 additions & 61 deletions core/graph/generated.go

Large diffs are not rendered by default.

25 changes: 17 additions & 8 deletions core/graph/http.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,14 @@ func getGraphHandler(w http.ResponseWriter, r *http.Request) {
}

func getAIModelsHandler(w http.ResponseWriter, r *http.Request) {
modelType := r.URL.Query().Get("modelType")
token := r.URL.Query().Get("token")
models, err := resolver.Query().AIModel(r.Context(), nil, modelType, &token)
providerId := r.URL.Query().Get("providerId")

if providerId == "" {
http.Error(w, "providerId is required", http.StatusBadRequest)
return
}

models, err := resolver.Query().AIModel(r.Context(), providerId)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
Expand All @@ -165,18 +170,22 @@ func getAIModelsHandler(w http.ResponseWriter, r *http.Request) {

func aiChatHandler(w http.ResponseWriter, r *http.Request) {
var req struct {
ModelType string `json:"modelType"`
Token string `json:"token"`
Schema string `json:"schema"`
Input model.ChatInput `json:"input"`
ProviderId string `json:"providerId"`
Schema string `json:"schema"`
Input model.ChatInput `json:"input"`
}

if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}

messages, err := resolver.Query().AIChat(r.Context(), nil, req.ModelType, &req.Token, req.Schema, req.Input)
if req.ProviderId == "" {
http.Error(w, "providerId is required", http.StatusBadRequest)
return
}

messages, err := resolver.Query().AIChat(r.Context(), req.ProviderId, req.Schema, req.Input)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
Expand Down
18 changes: 15 additions & 3 deletions core/graph/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 21 additions & 3 deletions core/graph/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,21 @@ type AIChatMessage {
}

type AIProvider {
Id: String!
Name: String!
Type: String!
ProviderId: String!
BaseURL: String
IsEnvironmentDefined: Boolean!
IsUserDefined: Boolean!
Settings: String
}

input AIProviderInput {
Name: String!
Type: String!
BaseURL: String
APIKey: String
Settings: String
}


Expand All @@ -169,8 +181,9 @@ type Query {
RawExecute(query: String!): RowsResult!
Graph(schema: String!): [GraphUnit!]!
AIProviders: [AIProvider!]!
AIModel(providerId: String, modelType: String!, token: String): [String!]!
AIChat(providerId: String, modelType: String!, token: String, schema: String!, input: ChatInput!): [AIChatMessage!]!
AIProvider(Id: String!): AIProvider
AIModel(providerId: String!): [String!]!
AIChat(providerId: String!, schema: String!, input: ChatInput!): [AIChatMessage!]!
SettingsConfig: SettingsConfig!
MockDataMaxRowCount: Int!
}
Expand All @@ -181,6 +194,11 @@ type Mutation {
Logout: StatusResponse!
UpdateSettings(newSettings: SettingsConfigInput!): StatusResponse!

# AI Provider management
CreateAIProvider(Provider: AIProviderInput!): AIProvider!
UpdateAIProvider(Id: String!, Provider: AIProviderInput!): AIProvider!
DeleteAIProvider(Id: String!): StatusResponse!

AddStorageUnit(schema: String!, storageUnit: String!, fields: [RecordInput!]!): StatusResponse!
UpdateStorageUnit(schema: String!, storageUnit: String!, values: [RecordInput!]!, updatedColumns: [String!]!): StatusResponse!
AddRow(schema: String!, storageUnit: String!, values: [RecordInput!]!): StatusResponse!
Expand Down
Loading