-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: merge ai from dev #7986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: merge ai from dev #7986
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,7 @@ func (u *AIToolService) Search(req dto.SearchWithPage) (int64, []dto.OllamaModel | |
| } | ||
| dtoLists = append(dtoLists, item) | ||
| } | ||
| return int64(total), dtoLists, err | ||
| return total, dtoLists, err | ||
| } | ||
|
|
||
| func (u *AIToolService) LoadDetail(name string) (string, error) { | ||
|
|
@@ -244,14 +244,18 @@ func (u *AIToolService) BindDomain(req dto.OllamaBindDomain) error { | |
| } | ||
| } | ||
| createWebsiteReq := request.WebsiteCreate{ | ||
| Domains: []request.WebsiteDomain{{Domain: req.Domain}}, | ||
| Domains: []request.WebsiteDomain{{Domain: req.Domain, Port: 80}}, | ||
| Alias: strings.ToLower(req.Domain), | ||
| Type: constant.Deployment, | ||
| AppType: constant.InstalledApp, | ||
| AppInstallID: req.AppInstallID, | ||
| } | ||
| if req.SSLID > 0 { | ||
| createWebsiteReq.WebsiteSSLID = req.SSLID | ||
| createWebsiteReq.EnableSSL = true | ||
| } | ||
| websiteService := NewIWebsiteService() | ||
| if err := websiteService.CreateWebsite(createWebsiteReq); err != nil { | ||
| if err = websiteService.CreateWebsite(createWebsiteReq); err != nil { | ||
| return err | ||
| } | ||
| website, err := websiteRepo.GetFirst(websiteRepo.WithAlias(strings.ToLower(req.Domain))) | ||
|
|
@@ -263,18 +267,6 @@ func (u *AIToolService) BindDomain(req dto.OllamaBindDomain) error { | |
| return err | ||
| } | ||
| } | ||
| if req.SSLID > 0 { | ||
| sslReq := request.WebsiteHTTPSOp{ | ||
| WebsiteID: website.ID, | ||
| Enable: true, | ||
| Type: "existed", | ||
| WebsiteSSLID: req.SSLID, | ||
| HttpConfig: "HTTPSOnly", | ||
| } | ||
| if _, err = websiteService.OpWebsiteHTTPS(context.Background(), sslReq); err != nil { | ||
| return err | ||
| } | ||
| } | ||
| if err = ConfigAIProxy(website); err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -295,6 +287,8 @@ func (u *AIToolService) GetBindDomain(req dto.OllamaBindDomainReq) (*dto.OllamaB | |
| res.Domain = website.PrimaryDomain | ||
| if website.WebsiteSSLID > 0 { | ||
| res.SSLID = website.WebsiteSSLID | ||
| ssl, _ := websiteSSLRepo.GetFirst(repo.WithByID(website.WebsiteSSLID)) | ||
| res.AcmeAccountID = ssl.AcmeAccountID | ||
| } | ||
| res.ConnUrl = fmt.Sprintf("%s://%s", strings.ToLower(website.Protocol), website.PrimaryDomain) | ||
| res.AllowIPs = GetAllowIps(website) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on the provided code snippet, I see no significant issues or irregularities. However, it would be beneficial to have proper checks for edge cases and potential errors that could occur when running this service. For example, make sure all required parameters are correctly received through requests such as name of AITool Service object ( Additionally, consider implementing more comprehensive testing, especially integration tests with mock data for unit testing. This will help identify regressions caused by minor changes without affecting production environment. Lastly, review comments and code structure carefully; if there’s complexity introduced while maintaining readability and maintainability, it might benefit from refactoring to improve its design architecture. Here's an updated version: package main // assuming package main has been removed
import (
"github.com/gin-gonic/gin"
)
// AIToolService contains services related to AI tools.
type AIToolService struct {
gin.IRouter
}
...This makes some improvements over the previous one like encapsulating logic into separate structs, using Go interfaces, and organizing common functionalities under their own packages. Let me know how you'd like us to proceed further! |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,5 +107,6 @@ export namespace AI { | |
| allowIPs: string[]; | ||
| websiteID?: number; | ||
| connUrl: string; | ||
| acmeAccountID: number; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,7 +116,15 @@ let refresh = ref(1); | |
| const httpPort = ref(0); | ||
| const httpsPort = ref(0); | ||
|
|
||
| const em = defineEmits(['setting', 'isExist', 'before', 'after', 'update:loading', 'update:maskShow']); | ||
| const em = defineEmits([ | ||
| 'setting', | ||
| 'isExist', | ||
| 'before', | ||
| 'after', | ||
| 'update:loading', | ||
| 'update:maskShow', | ||
| 'update:appInstallID', | ||
| ]); | ||
| const setting = () => { | ||
| em('setting', false); | ||
| }; | ||
|
|
@@ -128,6 +136,7 @@ const onCheck = async (key: any, name: any) => { | |
| em('isExist', res.data); | ||
| em('update:maskShow', res.data.status !== 'Running'); | ||
| operateReq.installId = res.data.appInstallId; | ||
| em('update:appInstallID', res.data.appInstallId); | ||
| httpPort.value = res.data.httpPort; | ||
| httpsPort.value = res.data.httpsPort; | ||
| refresh.value++; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry but my current knowledge cutoff is September 2021 so I cannot review the code you provided. Could you please check it first? |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key difference between the two structs is
AcmeAccountID, which was removed from the second version.No other notable differences in structure or content have been found. No issues or irregularities detected.
Potential optimizations could include:
WebsiteIDto something else that's not a reserved keyword.In terms of API design, this does not appear significant at this point. The primary goal here seems to be ensuring clarity without introducing complexity.