llm_client.go 675 B

123456789101112131415161718192021222324252627
  1. package llm
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. "time"
  6. )
  7. type LLMClient struct {
  8. BaseURL string
  9. HttpClient *http.Client
  10. }
  11. func NewLLMClient(baseURL string, timeout time.Duration) *LLMClient {
  12. return &LLMClient{
  13. BaseURL: baseURL,
  14. HttpClient: &http.Client{
  15. Timeout: timeout * time.Second,
  16. },
  17. }
  18. }
  19. type LLMService interface {
  20. KnowledgeBaseChat(query string, KnowledgeBaseName string, history []json.RawMessage) (llmRes *http.Response, err error)
  21. DocumentChat(query string, KnowledgeId string, history []json.RawMessage, stream bool) (llmRes *http.Response, err error)
  22. SearchKbDocs(query string, KnowledgeBaseName string) (data interface{}, err error)
  23. }