diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3a4c1b2..e3fcd60 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,9 +7,6 @@ on: - dev tags: - 'v*' - pull_request: - branches: [ "main" ] - #项目任务,任务之间可以并行调度 jobs: diff --git a/README.md b/README.md index 119e075..ed13f83 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,14 @@ # opencatd-open + GitHub Workflow Status +opencatd-open is an open-source, team-shared service for ChatGPT API that can be safely shared with others for API usage. + +--- OpenCat for Team的开源实现 -基本实现了opencatd的全部功能 +~~基本~~实现了opencatd的全部功能 ## 快速上手 ``` diff --git a/doc/azure.md b/doc/azure.md new file mode 100644 index 0000000..c190ddb --- /dev/null +++ b/doc/azure.md @@ -0,0 +1,4 @@ +# Azure OpenAI + +需要获取 api-key和endpoint +![](./azure_key%26endpoint.png) diff --git a/doc/azure_key&endpoint.png b/doc/azure_key&endpoint.png new file mode 100644 index 0000000..2a6362a Binary files /dev/null and b/doc/azure_key&endpoint.png differ diff --git a/pkg/azureopenai/azureopenai.go b/pkg/azureopenai/azureopenai.go index c14242f..f61d017 100644 --- a/pkg/azureopenai/azureopenai.go +++ b/pkg/azureopenai/azureopenai.go @@ -13,8 +13,46 @@ curl $AZURE_OPENAI_ENDPOINT/openai/deployments/gpt-35-turbo/chat/completions?api package azureopenai +import ( + "encoding/json" + "net/http" +) + var ( ENDPOINT string API_KEY string DEPLOYMENT_NAME string ) + +type ModelsList struct { + Data []struct { + ScaleSettings struct { + ScaleType string `json:"scale_type"` + } `json:"scale_settings"` + Model string `json:"model"` + Owner string `json:"owner"` + ID string `json:"id"` + Status string `json:"status"` + CreatedAt int `json:"created_at"` + UpdatedAt int `json:"updated_at"` + Object string `json:"object"` + } `json:"data"` + Object string `json:"object"` +} + +func Models(endpoint, apikey string) (*ModelsList, error) { + var modelsl ModelsList + req, _ := http.NewRequest(http.MethodGet, endpoint+"/openai/deployments?api-version=2022-12-01", nil) + req.Header.Set("api-key", apikey) + resp, err := http.DefaultClient.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + err = json.NewDecoder(resp.Body).Decode(&modelsl) + if err != nil { + return nil, err + } + return &modelsl, nil + +} diff --git a/store/keydb.go b/store/keydb.go index 3d623fe..05f6d9c 100644 --- a/store/keydb.go +++ b/store/keydb.go @@ -3,12 +3,15 @@ package store import "time" type Key struct { - ID uint `gorm:"primarykey" json:"id,omitempty"` - Key string `gorm:"unique;not null" json:"key,omitempty"` - Name string `gorm:"unique;not null" json:"name,omitempty"` - UserId string `json:"-,omitempty"` - CreatedAt time.Time `json:"createdAt,omitempty"` - UpdatedAt time.Time `json:"updatedAt,omitempty"` + ID uint `gorm:"primarykey" json:"id,omitempty"` + Key string `gorm:"unique;not null" json:"key,omitempty"` + Name string `gorm:"unique;not null" json:"name,omitempty"` + UserId string `json:"-,omitempty"` + KeyType string + EndPoint string + DeploymentName string + CreatedAt time.Time `json:"createdAt,omitempty"` + UpdatedAt time.Time `json:"updatedAt,omitempty"` } func GetKeyrByName(name string) (*Key, error) {