mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-10-12 10:47:30 +02:00
Add files via upload
This commit is contained in:
94 files changed
+27142
No files matched your search
@@ -0,0 +1,60 @@
|
||||
package llm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"cyberstrike-ai/internal/config"
|
||||
|
||||
agenticclaude "github.com/cloudwego/eino-ext/components/model/agenticclaude"
|
||||
"github.com/cloudwego/eino/components/model"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
)
|
||||
|
||||
func IsClaudeProvider(provider string) bool {
|
||||
provider = strings.ToLower(strings.TrimSpace(provider))
|
||||
return provider == "claude" || provider == "anthropic"
|
||||
}
|
||||
|
||||
func NewClaudeAgenticModel(
|
||||
ctx context.Context,
|
||||
cfg config.OpenAIConfig,
|
||||
httpClient *http.Client,
|
||||
maxTokens int,
|
||||
extraFields map[string]any,
|
||||
) (model.AgenticModel, error) {
|
||||
if maxTokens <= 0 {
|
||||
maxTokens = cfg.MaxCompletionTokensEffective()
|
||||
}
|
||||
if cfg.IsDeepSeekEndpointOrModel() {
|
||||
httpClient = newDeepSeekAnthropicCompatibleClient(httpClient)
|
||||
}
|
||||
return agenticclaude.New(ctx, &agenticclaude.Config{
|
||||
APIKey: strings.TrimSpace(cfg.APIKey),
|
||||
BaseURL: strings.TrimSuffix(strings.TrimSpace(cfg.BaseURL), "/"),
|
||||
Model: strings.TrimSpace(cfg.Model),
|
||||
MaxTokens: maxTokens,
|
||||
HTTPClient: httpClient,
|
||||
ExtraFields: extraFields,
|
||||
})
|
||||
}
|
||||
|
||||
func AgenticText(msg *schema.AgenticMessage) (content, reasoning string) {
|
||||
if msg == nil {
|
||||
return "", ""
|
||||
}
|
||||
var contentParts, reasoningParts []string
|
||||
for _, block := range msg.ContentBlocks {
|
||||
if block == nil {
|
||||
continue
|
||||
}
|
||||
switch {
|
||||
case block.AssistantGenText != nil:
|
||||
contentParts = append(contentParts, block.AssistantGenText.Text)
|
||||
case block.Reasoning != nil:
|
||||
reasoningParts = append(reasoningParts, block.Reasoning.Text)
|
||||
}
|
||||
}
|
||||
return strings.Join(contentParts, ""), strings.Join(reasoningParts, "")
|
||||
}
|
||||
Reference in new issue
Block a user