fix: remove internal url from code

This commit is contained in:
lilong.129
2025-07-20 23:47:41 +08:00
parent 9890588ca7
commit 8b83f3ac78

View File

@@ -16,41 +16,40 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v5/code"
"github.com/httprunner/httprunner/v5/internal/builtin" "github.com/httprunner/httprunner/v5/internal/builtin"
) )
// WingsService implements ILLMService interface using external Wings API // WingsService implements ILLMService interface using external Wings API
type WingsService struct { type WingsService struct {
apiURL string apiURL string
bizId string bizId string
isExternal bool accessKey string
accessKey string secretKey string
secretKey string
} }
// NewWingsService creates a new Wings service instance // NewWingsService creates a new Wings service instance
func NewWingsService() ILLMService { func NewWingsService() (ILLMService, error) {
// Check for environment variables for external API access // Check for environment variables for external API access
accessKey := "" apiURL := os.Getenv("VEDEM_WINGS_API_URL")
secretKey := "" accessKey := os.Getenv("VEDEM_WINGS_AK")
isExternal := false secretKey := os.Getenv("VEDEM_WINGS_SK")
apiURL := "https://vedem-algorithm.bytedance.net/algorithm/StepActionDecision" bizID := os.Getenv("VEDEM_WINGS_BIZ_ID")
// If environment variables are set, use external API with authentication // check required env
if ak, sk := os.Getenv("VEDEM_WINGS_AK"), os.Getenv("VEDEM_WINGS_SK"); ak != "" && sk != "" { if apiURL == "" {
accessKey = ak return nil, errors.Wrap(code.LLMEnvMissedError, "missed env VEDEM_WINGS_API_URL")
secretKey = sk }
isExternal = true if bizID == "" {
apiURL = "https://vedem-algorithm.zijieapi.com/algorithm/StepActionDecision" return nil, errors.Wrap(code.LLMEnvMissedError, "missed env VEDEM_WINGS_BIZ_ID")
} }
return &WingsService{ return &WingsService{
apiURL: apiURL, apiURL: apiURL,
bizId: "489fdae44de048e0922a32834ea668af", bizId: bizID,
isExternal: isExternal, accessKey: accessKey,
accessKey: accessKey, secretKey: secretKey,
secretKey: secretKey, }, nil
}
} }
// Plan implements the ILLMService.Plan method using Wings API // Plan implements the ILLMService.Plan method using Wings API
@@ -409,7 +408,7 @@ func (w *WingsService) callWingsAPI(ctx context.Context, request WingsActionRequ
httpReq.Header.Set("Accept", "application/json") httpReq.Header.Set("Accept", "application/json")
// Add authentication headers if using external API // Add authentication headers if using external API
if w.isExternal { if w.accessKey != "" && w.secretKey != "" {
signToken := "UNSIGNED-PAYLOAD" signToken := "UNSIGNED-PAYLOAD"
token := builtin.Sign("auth-v2", w.accessKey, w.secretKey, []byte(signToken)) token := builtin.Sign("auth-v2", w.accessKey, w.secretKey, []byte(signToken))