Skip to content

Commit cbbfc44

Browse files
committed
bug fixes
1 parent cc35e7f commit cbbfc44

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

controllers/llm_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (c *LlmController) GenerateNotebookHandler(w http.ResponseWriter, r *http.R
4747
}
4848
}
4949

50-
// ModifyNotebookHandler handles POST /api/v1/llm/sessions/{session_id}/modify
50+
// ModifyNotebookHandler handles POST /api/v1/llm/sessions/modify
5151
func (c *LlmController) ModifyNotebookHandler(w http.ResponseWriter, r *http.Request) {
5252
sessionID := r.PathValue("session_id")
5353
ctx := r.Context()
@@ -68,7 +68,7 @@ func (c *LlmController) ModifyNotebookHandler(w http.ResponseWriter, r *http.Req
6868
}
6969
}
7070

71-
// FixNotebookHandler handles POST /api/v1/llm/sessions/{session_id}/fix
71+
// FixNotebookHandler handles POST /api/v1/llm/sessions/fix
7272
func (c *LlmController) FixNotebookHandler(w http.ResponseWriter, r *http.Request) {
7373
sessionID := r.PathValue("session_id")
7474
ctx := r.Context()

modules/llm_module.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (m *LlmModule) GenerateNotebook(ctx context.Context, body io.Reader) (*http
3030
return nil, fmt.Errorf("failed to read request body: %w", err)
3131
}
3232

33-
var requestData map[string]interface{}
33+
var requestData map[string]any
3434
if err := json.Unmarshal(bodyBytes, &requestData); err != nil {
3535
return nil, fmt.Errorf("failed to decode request body as JSON: %w", err)
3636
}
@@ -54,7 +54,7 @@ func (m *LlmModule) ModifyNotebook(ctx context.Context, sessionID string, body i
5454
return nil, fmt.Errorf("failed to read request body: %w", err)
5555
}
5656

57-
var requestData map[string]interface{}
57+
var requestData map[string]any
5858
if err := json.Unmarshal(bodyBytes, &requestData); err != nil {
5959
return nil, fmt.Errorf("failed to decode request body as JSON: %w", err)
6060
}
@@ -67,12 +67,12 @@ func (m *LlmModule) ModifyNotebook(ctx context.Context, sessionID string, body i
6767
return nil, fmt.Errorf("request body must contain a non-empty 'instruction' string")
6868
}
6969

70-
currentNotebook, ok := requestData["current_notebook"].(map[string]interface{})
70+
currentNotebook, ok := requestData["notebook"].(map[string]any)
7171
if !ok {
72-
return nil, fmt.Errorf("request body must contain a 'current_notebook' object")
72+
return nil, fmt.Errorf("request body must contain a 'notebook' object")
7373
}
74-
if _, ok := currentNotebook["cells"].([]interface{}); !ok {
75-
return nil, fmt.Errorf("'current_notebook' object must contain a 'cells' array")
74+
if _, ok := currentNotebook["cells"].([]any); !ok {
75+
return nil, fmt.Errorf("'notebook' object must contain a 'cells' array")
7676
}
7777

7878
return m.Repo.ModifyNotebook(ctx, bytes.NewBuffer(bodyBytes))
@@ -85,7 +85,7 @@ func (m *LlmModule) FixNotebook(ctx context.Context, sessionID string, body io.R
8585
return nil, fmt.Errorf("failed to read request body: %w", err)
8686
}
8787

88-
var requestData map[string]interface{}
88+
var requestData map[string]any
8989
if err := json.Unmarshal(bodyBytes, &requestData); err != nil {
9090
return nil, fmt.Errorf("failed to decode request body as JSON: %w", err)
9191
}
@@ -98,18 +98,18 @@ func (m *LlmModule) FixNotebook(ctx context.Context, sessionID string, body io.R
9898
return nil, fmt.Errorf("request body must contain a non-empty 'traceback' string")
9999
}
100100

101-
currentNotebook, ok := requestData["current_notebook"].(map[string]interface{})
101+
currentNotebook, ok := requestData["notebook"].(map[string]any)
102102
if !ok {
103-
return nil, fmt.Errorf("request body must contain a 'current_notebook' object")
103+
return nil, fmt.Errorf("request body must contain a 'notebook' object")
104104
}
105-
if _, ok := currentNotebook["cells"].([]interface{}); !ok {
106-
return nil, fmt.Errorf("'current_notebook' object must contain a 'cells' array")
105+
if _, ok := currentNotebook["cells"].([]any); !ok {
106+
return nil, fmt.Errorf("'notebook' object must contain a 'cells' array")
107107
}
108108

109109
return m.Repo.FixNotebook(ctx, bytes.NewBuffer(bodyBytes))
110110
}
111111

112-
func IsUserIDandNotebookIDPresent(requestData map[string]interface{}) error {
112+
func IsUserIDandNotebookIDPresent(requestData map[string]any) error {
113113
// TODO: User ID should not be passed in the body.
114114
// TODO: It should be extracted from the auth context, which i am not going to do now :)
115115
// making sure user_id and notebook_id are present

routes/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ func RegisterAPIRoutes(mux *http.ServeMux, c *jupyterclient.Client) { // Updated
8181

8282
// Llm Routes
8383
mux.HandleFunc("POST /api/v1/llm/generate", llmController.GenerateNotebookHandler)
84-
mux.HandleFunc("POST /api/v1/llm/sessions/{session_id}/modify", llmController.ModifyNotebookHandler)
85-
mux.HandleFunc("POST /api/v1/llm/sessions/{session_id}/fix", llmController.FixNotebookHandler)
84+
mux.HandleFunc("POST /api/v1/llm/modify", llmController.ModifyNotebookHandler)
85+
mux.HandleFunc("POST /api/v1/llm/fix", llmController.FixNotebookHandler)
8686

8787
// Kernel Routes
8888
mux.HandleFunc("POST /api/v1/kernels", kernelController.StartKernelHandler)

0 commit comments

Comments
 (0)