Add testimonials
This commit is contained in:
parent
06e943d478
commit
40223a12b5
7 changed files with 318 additions and 101 deletions
|
|
@ -71,7 +71,8 @@ func (p LlamaServerProvider) Health() (err error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p LlamaServerProvider) Complete(ctx context.Context, prompt string) (response string, err error) {
|
||||
func (p LlamaServerProvider) Complete(ctx context.Context, prompt string, schema any) (response string, err error) {
|
||||
// TODO: schema enforcement
|
||||
req := Request{
|
||||
Messages: []Message{
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,16 +22,13 @@ type Message struct {
|
|||
}
|
||||
|
||||
type ChatCompletionRequest struct {
|
||||
Model string `json:"model"`
|
||||
Messages []Message `json:"messages"`
|
||||
Temperature *float64 `json:"temperature,omitempty"`
|
||||
MaxTokens *int `json:"max_tokens,omitempty"`
|
||||
TopP *float64 `json:"top_p,omitempty"`
|
||||
Stop json.RawMessage `json:"stop,omitempty"` // string or []string; keep flexible
|
||||
Provider struct {
|
||||
Model string `json:"model"`
|
||||
Messages []Message `json:"messages"`
|
||||
Provider struct {
|
||||
Sort string `json:"sort,omitempty"`
|
||||
} `json:"provider,omitempty"`
|
||||
|
||||
ResponseFormat any `json:"response_format,omitempty"` // keep flexible
|
||||
Plugins []map[string]string `json:"plugins,omitempty"`
|
||||
}
|
||||
|
||||
type ChatCompletionResponse struct {
|
||||
|
|
@ -46,7 +43,7 @@ type ChatCompletionResponse struct {
|
|||
} `json:"choices"`
|
||||
}
|
||||
|
||||
func (p OpenRouterProvider) Complete(ctx context.Context, prompt string) (string, error) {
|
||||
func (p OpenRouterProvider) Complete(ctx context.Context, prompt string, schema any) (string, error) {
|
||||
req := ChatCompletionRequest{
|
||||
Model: p.Model,
|
||||
Messages: []Message{
|
||||
|
|
@ -62,6 +59,18 @@ func (p OpenRouterProvider) Complete(ctx context.Context, prompt string) (string
|
|||
},
|
||||
}
|
||||
|
||||
if schema != nil {
|
||||
req.ResponseFormat = map[string]any{
|
||||
"type": "json_schema",
|
||||
"json_schema": schema,
|
||||
}
|
||||
req.Plugins = []map[string]string{
|
||||
{
|
||||
"id": "response-healing",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
httpClient := http.Client{Timeout: 10 * time.Second}
|
||||
body, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ package completion
|
|||
import "context"
|
||||
|
||||
type CompletionProvider interface {
|
||||
Complete(ctx context.Context, prompt string) (string, error)
|
||||
Complete(ctx context.Context, prompt string, schema any) (string, error)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue