Documentation
¶
Overview ¶
Package huggingface implements the Hugging Face provider.
Index ¶
Constants ¶
View Source
const Name = "huggingface"
Name of the provider.
Variables ¶
This section is empty.
Functions ¶
func ProcessResponse ¶
func ProcessResponse(resp ResponseBody) (string, error)
ProcessResponse processes the response from the API.
Types ¶
type Choice ¶
type Choice struct {
FinishReason string `json:"finish_reason"`
Index int `json:"index"`
Message message.Message `json:"message"`
}
Choice HuggingFace API definition.
type HuggingFace ¶
type HuggingFace struct {
*provider.Provider
// Endpoint of the LLM provider.
Endpoint string `json:"url" validate:"required"`
// Token of the LLM provider.
Token string `json:"-" validate:"required"`
// contains filtered or unexported fields
}
HuggingFace provider definition.
func New ¶
func New( options ...provider.ClientFunc, ) (*HuggingFace, error)
New creates a new HuggingFace provider.
func NewDefault ¶
func NewDefault(options ...provider.ClientFunc) (*HuggingFace, error)
NewDefault creates a new HuggingFace provider with default values.
func (*HuggingFace) Completion ¶
Completion generates a completion using the provider API. Optionally pass WithResponseBody to unmarshal the response body. It will always return the original, unparsed response body, if no error.
NOTE: Not all options are available for all providers.
type RequestBody ¶
type RequestBody struct {
Messages []message.Message `json:"messages"`
Model string `json:"model"`
Stream bool `json:"stream"`
MaxTokens int `json:"max_tokens,omitempty"`
Seed int `json:"seed,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
}
RequestBody represents the request body for the API.
Click to show internal directories.
Click to hide internal directories.