mirror of
https://github.com/hanzoai/ai.git
synced 2026-11-21 11:09:56 +00:00
* feat: rename module path cloud→ai + cloud Mount() per HIP-0106 The repo at hanzoai/ai was renamed from hanzoai/cloud on 2026-05-19. This rotates the Go module path to match so the unified cloud binary (hanzoai/cloud) can import this subsystem under its new name. Module rename: - go.mod: module github.com/hanzoai/cloud → module github.com/hanzoai/ai - 236 .go files: import github.com/hanzoai/cloud/... → github.com/hanzoai/ai/... - cloud.zap → schema/ai.zap (header + interface CloudService → interface AI) HIP-0106 Mount: - pkg/ai.Mount(*zip.App, cloud.Deps) error registers /v1/ai/* on the unified binary; the route layer strips the /v1/ai prefix and forwards to the beego ControllerRegister via zip.AdaptNetHTTP. - A SetHandler injector lets main.go publish beego.BeeApp.Handlers after route init so the in-process embed and the standalone server share the same route table; X-Org-Id call-sites stay unchanged. - schema/ai.zap describes the typed ZAP surface (chat, embeddings, knowledge / RAG, billing). * refactor(consumer): import github.com/hanzoai/iam (drop iamsdk/v2) Switch from github.com/hanzoai/iamsdk/v2/iamsdk to the canonical github.com/hanzoai/iam root package. One canonical import path for both the server and the SDK — same types, no drift. iamsdk "github.com/hanzoai/iamsdk/v2/iamsdk" → iam "github.com/hanzoai/iam" iamsdk.Claims, iamsdk.User, … → iam.Claims, iam.User, … 23 files updated across controllers/, object/, routers/, storage/, util/. go.mod: dropped iamsdk/v2 require, pinned iam to its current SHA v1.16.2-0.20260519061152-86e34e93edf3 (drops cloud+zip transitive deps via root SDK; submodule pkg/iam carries the cloud integration). Pre-existing pkgmachine/gcp.go GCP API breakage (InstancesClient relocated from computepb to apiv1 in compute v1.47+) is unaffected by this change and not in scope. * refactor: collapse pkg/ai/ → root + flatten cloud import Repo IS the package. Mount() at root. Consumers use `github.com/hanzoai/ai` (no /pkg/ai/ nesting).
98 lines
2.8 KiB
Go
98 lines
2.8 KiB
Go
// Copyright 2023-2025 Hanzo AI Inc.. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package controllers
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/hanzoai/ai/object"
|
|
)
|
|
|
|
// CommitRecord
|
|
// @Title CommitRecord
|
|
// @Tag Record API
|
|
// @Description commit a record
|
|
// @Param body body object.Record true "The details of the record"
|
|
// @Success 200 {object} controllers.Response The Response object
|
|
// @router /commit-record [post]
|
|
func (c *ApiController) CommitRecord() {
|
|
var record object.Record
|
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &record)
|
|
if err != nil {
|
|
c.ResponseError(err.Error())
|
|
return
|
|
}
|
|
|
|
c.Data["json"] = wrapActionResponse2(object.CommitRecord(&record, c.GetAcceptLanguage()))
|
|
c.ServeJSON()
|
|
}
|
|
|
|
// CommitRecordSecond
|
|
// @Title CommitRecordSecond
|
|
// @Tag Record API
|
|
// @Description commit a record
|
|
// @Param body body object.Record true "The details of the record"
|
|
// @Success 200 {object} controllers.Response The Response object
|
|
// @router /commit-record-second [post]
|
|
func (c *ApiController) CommitRecordSecond() {
|
|
var record object.Record
|
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &record)
|
|
if err != nil {
|
|
c.ResponseError(err.Error())
|
|
return
|
|
}
|
|
|
|
c.Data["json"] = wrapActionResponse(object.CommitRecordSecond(&record, c.GetAcceptLanguage()))
|
|
c.ServeJSON()
|
|
}
|
|
|
|
// QueryRecord
|
|
// @Title QueryRecord
|
|
// @Tag Record API
|
|
// @Description query record
|
|
// @Param id query string true "The id ( owner/name ) of the record"
|
|
// @Success 200 {object} object.Record The Response object
|
|
// @router /query-record [get]
|
|
func (c *ApiController) QueryRecord() {
|
|
id := c.Input().Get("id")
|
|
|
|
res, err := object.QueryRecord(id, c.GetAcceptLanguage())
|
|
if err != nil {
|
|
c.ResponseError(err.Error())
|
|
return
|
|
}
|
|
|
|
c.ResponseOk(res)
|
|
}
|
|
|
|
// QueryRecordSecond
|
|
// @Title QueryRecordSecond
|
|
// @Tag Record API
|
|
// @Description query record
|
|
// @Param id query string true "The id ( owner/name ) of the record"
|
|
// @Success 200 {object} object.Record The Response object
|
|
// @router /query-record-second [get]
|
|
func (c *ApiController) QueryRecordSecond() {
|
|
id := c.Input().Get("id")
|
|
|
|
res, err := object.QueryRecordSecond(id, c.GetAcceptLanguage())
|
|
if err != nil {
|
|
c.ResponseError(err.Error())
|
|
return
|
|
}
|
|
|
|
c.ResponseOk(res)
|
|
}
|