client

package
v0.0.0-...-5b550e9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

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

func NewDefaultClient(password, url string) *Client

NewDefaultClient initializes a new Client instance with default implementations

func NewGZipClient

func NewGZipClient(password, url string) *Client

NewGZipClient initializes a new Client instance with GZip compression for requests

func (*Client) GrpcGenerateObject

func (c *Client) GrpcGenerateObject(prompt string, definition *pb.Definition) (*Response, error)

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

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

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

type Res struct {
	Value string                 `json:"value"`
	Other map[string]interface{} `json:"Other"`
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL