llm_client.go 942 B

12345678910111213141516171819202122232425262728293031
  1. package llm
  2. import (
  3. "encoding/json"
  4. "eta/eta_api/utils/llm/eta_llm/eta_llm_http"
  5. "net/http"
  6. "os"
  7. "time"
  8. )
  9. type LLMClient struct {
  10. BaseURL string
  11. HttpClient *http.Client
  12. }
  13. func NewLLMClient(baseURL string, timeout time.Duration) *LLMClient {
  14. return &LLMClient{
  15. BaseURL: baseURL,
  16. HttpClient: &http.Client{
  17. Timeout: timeout * time.Second,
  18. },
  19. }
  20. }
  21. type LLMService interface {
  22. KnowledgeBaseChat(query string, KnowledgeBaseName string, history []json.RawMessage) (llmRes *http.Response, err error)
  23. DocumentChat(query string, KnowledgeId string, history []json.RawMessage, stream bool) (llmRes *http.Response, err error)
  24. SearchKbDocs(query string, KnowledgeBaseName string) (data interface{}, err error)
  25. UploadFileToTemplate(files []*os.File, param map[string]interface{}) (data interface{}, err error)
  26. FileChat(query string, KnowledgeId string, history []json.RawMessage) (resp eta_llm_http.BaseResponse, err error)
  27. }