Documentation
¶
Overview ¶
Package modelstest fakes the HTTP APIs of the cloud model providers the embedded gateway calls: Azure OpenAI's v1 API, Amazon Bedrock's Converse and InvokeModel, and Vertex AI's generateContent with a Google OAuth token endpoint. Each fake records the requests it gets, answers a request that offers tools with a call of the first tool and any other with "OK", and can be told to fail. They cover what kōjō sends and reads, not the APIs.
Index ¶
Constants ¶
const VertexToken = "ya29.fake-vertex-access-token"
VertexToken is the access token the Vertex fake's token endpoint issues.
Variables ¶
This section is empty.
Functions ¶
func AWSCredentials ¶
AWSCredentials gives the AWS SDK's default chain static credentials from the environment and nothing else to find: no shared config files, no instance metadata, no Bedrock API key, no endpoint override.
func GoogleCredentials ¶
GoogleCredentials points Application Default Credentials at a key file whose tokens come from the Vertex fake, and clears the variables that would change where requests go.
func VertexCredentials ¶
VertexCredentials writes a service account key file whose token endpoint is the fake's, and returns its path: point GOOGLE_APPLICATION_CREDENTIALS at it and Application Default Credentials get their token from the fake.
func VertexPath ¶
VertexPath is the path of a Vertex AI model method under the pinned API version.
Types ¶
type Request ¶
type Request struct {
Method string
// Path is the decoded path; RawPath is as sent.
Path string
RawPath string
Header http.Header
Body map[string]any
}
Request is one request a fake received.
type Server ¶
type Server struct {
URL string
// contains filtered or unexported fields
}
Server is a fake provider API.
func Azure ¶
Azure fakes the v1 API of an Azure OpenAI or Foundry resource: POST /openai/v1/chat/completions and /openai/v1/embeddings.
func Bedrock ¶
Bedrock fakes Bedrock Runtime: POST /model/{id}/converse, and /model/{id}/invoke for Amazon Titan text embeddings.
func BedrockTLS ¶
BedrockTLS is Bedrock over https, which a Bedrock API key needs. It returns the file of the certificate to trust (AWS_CA_BUNDLE).
func Vertex ¶
Vertex fakes Vertex AI under /v1beta1/projects/{p}/locations/{l}/publishers/google/models/{m} (generateContent, and predict and embedContent for embeddings) and an OAuth token endpoint at /token, for the key file of VertexCredentials.
func (*Server) Fail ¶
Fail makes every model and embedding request answer with this status and body; 0 turns it off. Token requests still succeed.