Transforms LLM requests to OpenAI completion API calls and parses responses.
// Source: https://github.com/looplj/axonhub | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package openai
import (
"bytes"
"context"
"encoding/json"
"fmt"
"net/http"
"strings"
"github.com/looplj/axonhub/llm"
"github.com/looplj/axonhub/llm/httpclient"
"github.com/looplj/axonhub/llm/streams"
"github.com/looplj/axonhub/llm/transformer"
)
type CompletionOutboundTransformer struct {
config *Config
}
func NewCompletionOutboundTransformer(config *Config) (transformer.Outbound, error) {
if config == nil {
return nil, fmt.Errorf("config cannot be nil")
}
if config.APIKeyProvider == nil {
return nil, fmt.Errorf("API key provider is required")
}
if config.BaseURL
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key