43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package analyzer
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"git.pengzhan.dev/haopengzhan/hireme/internal/config"
|
|
)
|
|
|
|
type AnalysisOutput struct {
|
|
AIScore float64 `json:"ai_score"`
|
|
IsQualified bool `json:"is_qualified"`
|
|
Summary string `json:"summary"`
|
|
MatchedHighlights []string `json:"matched_highlights"`
|
|
MissingHighlights []string `json:"missing_highlights"`
|
|
TailoringSuggestions []string `json:"tailoring_suggestions"`
|
|
}
|
|
|
|
type LLMAnalyzer interface {
|
|
AnalyzeJD(ctx context.Context, jobTitle, rawContent string) (*AnalysisOutput, error)
|
|
}
|
|
|
|
func NewAnalyzer(cfg *config.Config) (LLMAnalyzer, error) {
|
|
provider := strings.ToLower(cfg.LLMProvider)
|
|
switch provider {
|
|
case "gemini":
|
|
if cfg.GeminiAPIKey == "" {
|
|
return nil, fmt.Errorf("GEMINI_API_KEY is required for provider 'gemini'")
|
|
}
|
|
return NewGeminiAnalyzer(cfg.GeminiAPIKey, cfg.SystemPrompt, cfg.UserPrompt), nil
|
|
case "deepseek":
|
|
if cfg.DeepSeekAPIKey == "" {
|
|
return nil, fmt.Errorf("DEEPSEEK_API_KEY is required for provider 'deepseek'")
|
|
}
|
|
return NewDeepSeekAnalyzer(cfg.DeepSeekAPIKey, cfg.DeepSeekBaseURL, cfg.SystemPrompt, cfg.UserPrompt), nil
|
|
case "mock":
|
|
return NewMockAnalyzer(), nil
|
|
default:
|
|
return NewMockAnalyzer(), nil
|
|
}
|
|
}
|