| 549 | } |
| 550 | |
| 551 | func (i *imlServiceModule) Get(ctx context.Context, id string) (*service_dto.Service, error) { |
| 552 | now := time.Now() |
| 553 | serviceInfo, err := i.serviceService.Get(ctx, id) |
| 554 | if err != nil { |
| 555 | return nil, err |
| 556 | } |
| 557 | tags, err := i.serviceTagService.List(ctx, []string{serviceInfo.Id}, nil) |
| 558 | if err != nil { |
| 559 | return nil, err |
| 560 | } |
| 561 | |
| 562 | s := service_dto.ToService(serviceInfo) |
| 563 | s.Tags = auto.List(utils.SliceToSlice(tags, func(p *service_tag.Tag) string { |
| 564 | return p.Tid |
| 565 | })) |
| 566 | if s.Model == "" { |
| 567 | switch s.ProviderType { |
| 568 | case "online": |
| 569 | p, has := model_runtime.GetProvider(s.Provider.Id) |
| 570 | if has { |
| 571 | m, has := p.DefaultModel(model_runtime.ModelTypeLLM) |
| 572 | if has { |
| 573 | s.Model = m.ID() |
| 574 | } |
| 575 | } |
| 576 | case "local": |
| 577 | info, err := i.localModelService.DefaultModel(ctx) |
| 578 | if err != nil { |
| 579 | return nil, err |
| 580 | } |
| 581 | s.Model = info.Id |
| 582 | |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | serviceModelMapping, err := i.serviceModelMappingService.Get(ctx, id) |
| 587 | if err != nil { |
| 588 | return nil, err |
| 589 | } |
| 590 | s.ModelMapping = serviceModelMapping.Content |
| 591 | |
| 592 | log.Infof("get service cost %d ms", time.Since(now).Milliseconds()) |
| 593 | return s, nil |
| 594 | } |
| 595 | |
| 596 | func (i *imlServiceModule) Search(ctx context.Context, teamID string, keyword string) ([]*service_dto.ServiceItem, error) { |
| 597 | var list []*service.Service |