(ctx context.Context, serviceId string, logId string)
| 150 | } |
| 151 | |
| 152 | func (i *imlServiceModule) AILogInfo(ctx context.Context, serviceId string, logId string) (*service_dto.AILogInfo, error) { |
| 153 | c, err := i.clusterService.Get(ctx, cluster.DefaultClusterID) |
| 154 | if err != nil { |
| 155 | return nil, fmt.Errorf("cluster %s not found", cluster.DefaultClusterID) |
| 156 | } |
| 157 | info, err := i.logService.LogInfo(ctx, "loki", c.Cluster, logId) |
| 158 | if err != nil { |
| 159 | return nil, err |
| 160 | } |
| 161 | if info.Service != serviceId { |
| 162 | return nil, errors.New("service not match") |
| 163 | } |
| 164 | response, err := parseAIResponse(info.ResponseBody) |
| 165 | if err != nil { |
| 166 | response = info.ResponseBody |
| 167 | } |
| 168 | |
| 169 | logInfo := &service_dto.AILogInfo{ |
| 170 | Id: info.ID, |
| 171 | API: auto.UUID(info.API), |
| 172 | Consumer: auto.UUID(info.Consumer), |
| 173 | Status: info.StatusCode, |
| 174 | Ip: info.RemoteIP, |
| 175 | Provider: auto.UUID(info.AIProvider), |
| 176 | Model: info.AIModel, |
| 177 | LogTime: auto.TimeLabel(info.RecordTime), |
| 178 | Request: service_dto.OriginAIRequest{ |
| 179 | OriginRequest: service_dto.OriginRequest{ |
| 180 | Header: formatHeader(info.RequestHeader), |
| 181 | Origin: info.RequestBody, |
| 182 | Body: parseAIRequest(info.RequestBody), |
| 183 | }, |
| 184 | |
| 185 | Token: info.InputToken, |
| 186 | }, |
| 187 | Response: service_dto.OriginAIRequest{ |
| 188 | OriginRequest: service_dto.OriginRequest{ |
| 189 | Header: formatHeader(info.ResponseHeader), |
| 190 | Origin: info.ResponseBody, |
| 191 | Body: response, |
| 192 | }, |
| 193 | |
| 194 | Token: info.OutputToken, |
| 195 | }, |
| 196 | } |
| 197 | if info.Consumer == "apipark-global" { |
| 198 | logInfo.IsSystemConsumer = true |
| 199 | logInfo.Consumer = auto.Label{ |
| 200 | Id: info.Consumer, |
| 201 | Name: "System Consumer", |
| 202 | } |
| 203 | } |
| 204 | return logInfo, nil |
| 205 | } |
| 206 | |
| 207 | func (i *imlServiceModule) RestLogs(ctx context.Context, serviceId string, start int64, end int64, page int, size int) ([]*service_dto.RestLogItem, int64, error) { |
| 208 | list, total, err := i.logService.LogRecordsByService(ctx, serviceId, time.Unix(start, 0), time.Unix(end, 0), page, size) |
nothing calls this directly
no test coverage detected