Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteRequest ¶
func ExecuteRequest(currentGen map[string]any, d *jsonSchema.Definition) (*http.Response, error)
ExecuteRequest executes an HTTP request based on the RequestFormat
Types ¶
type Client ¶
type Client struct { Password string BaseURL string HttpClient HttpClient RequestSender RequestSender ResponseProcessor ResponseProcessor }
Client responsible for holding base configuration and dependencies
func NewDefaultClient ¶
NewDefaultClient initializes a new Client instance with default implementations
func NewGZipClient ¶
NewGZipClient initializes a new Client instance with GZip compression for requests
func (*Client) GrpcGenerateObject ¶
SendRequestToServer sends a request to the gRPC server with authorization headers
func (*Client) SendRequest ¶
func (c *Client) SendRequest(prompt string, definition *jsonSchema.Definition) (*Response, error)
SendRequest sends the prompt and definition, and returns the parsed response
type DefaultRequestSender ¶
type DefaultRequestSender struct{}
DefaultRequestSender is a default implementation of RequestSender
func NewDefaultRequestSender ¶
func NewDefaultRequestSender() *DefaultRequestSender
NewDefaultRequestSender initializes a new DefaultRequestSender
func (*DefaultRequestSender) SendRequestBody ¶
func (rs *DefaultRequestSender) SendRequestBody(baseURL, token string, requestBody *RequestBody) (*http.Response, error)
SendRequestBody sends a JSON request and returns a response
type GZipRequestSender ¶
type GZipRequestSender struct{}
GZipRequestSender is a request sender that compresses the request body using gzip
func NewGZipRequestSender ¶
func NewGZipRequestSender() *GZipRequestSender
NewGZipRequestSender initializes a new GZipRequestSender
func (*GZipRequestSender) SendRequestBody ¶
func (grs *GZipRequestSender) SendRequestBody(baseURL, token string, requestBody *RequestBody) (*http.Response, error)
SendRequestBody sends a gzip-compressed JSON request and returns a response
type HttpClient ¶
HttpClient interface to abstract HTTP operations
type RequestBody ¶
type RequestBody struct { Prompt string `json:"prompt"` Definition *jsonSchema.Definition `json:"definition"` }
type RequestSender ¶
type RequestSender interface {
SendRequestBody(url, token string, requestBody *RequestBody) (*http.Response, error)
}
RequestSender interface abstracts request sending behavior
type Res ¶
Res defines a structure with a single string field
func SendRequest ¶
func SendRequest(def *jsonSchema.Definition, currentGen map[string]any) *Res
the below occurs within the internal workings (i think)
type Response ¶
type Response struct { Data map[string]any `json:"data"` //this data can then be marshalled into the apprioate object type. UsdCost float64 `json:"usdCost"` }
Create a response struct
type ResponseProcessor ¶
type ResponseProcessor struct{}
ResponseProcessor responsible for processing the HTTP response
func NewResponseProcessor ¶
func NewResponseProcessor() ResponseProcessor
NewResponseProcessor initializes a new ResponseProcessor
func (*ResponseProcessor) ProcessResponse ¶
func (rp *ResponseProcessor) ProcessResponse(resp *http.Response) (*Response, error)
ProcessResponse processes the response and returns the parsed Response struct