Documentation ¶
Overview ¶
package defines diagram as code using the graph input
Index ¶
- Constants
- func WithHTTPClientOpenAI(c HttpClient) func(o *clientOpenAI)
- func WithHTTPClientPlantUML(c HttpClient) func(*optionsPlantUMLClient)
- func WithSinkFn(sinkFn func(string)) func(o *clientOpenAI)
- type CallID
- type ClientGraphToDiagram
- type ClientInputToGraph
- type ClientStorage
- type ConfigOpenAI
- type DiagramGraph
- type Error
- type HttpClient
- type Link
- type MockClientStorage
- type ModelOutput
- type Node
- type ResponseC4Diagram
- type ResponseDiagram
- type UserInput
Constants ¶
const ( ServiceOpenAI = "OpenAI" ServiePlantUML = "PlantUML" ServiceStorage = "Storage" )
const ( StageInit = "init" StageRequest = "request" StageResponse = "response" StageSerialization = "serialization" StageDeserialization = "deserialization" )
Variables ¶
This section is empty.
Functions ¶
func WithHTTPClientOpenAI ¶
func WithHTTPClientOpenAI(c HttpClient) func(o *clientOpenAI)
WithHTTPClientOpenAI overwrite the OpenAI HTTP client.
func WithHTTPClientPlantUML ¶
func WithHTTPClientPlantUML(c HttpClient) func(*optionsPlantUMLClient)
WithHTTPClientPlantUML overwrite the PlantUML HTTP client.
func WithSinkFn ¶
func WithSinkFn(sinkFn func(string)) func(o *clientOpenAI)
WithSinkFn sets sink function to record model's input and output.
Types ¶
type ClientGraphToDiagram ¶
type ClientGraphToDiagram interface {
Do(context.Context, DiagramGraph) (ResponseDiagram, error)
}
ClientGraphToDiagram client to convert DiagramGraph to diagram artifact, e.g. svg image.
func NewPlantUMLClient ¶
func NewPlantUMLClient(optFns ...func(*optionsPlantUMLClient)) ClientGraphToDiagram
NewPlantUMLClient initiates the clientPlantUML to communicate with the plantuml server.
type ClientInputToGraph ¶
type ClientInputToGraph interface {
Do(context.Context, string) (DiagramGraph, error)
}
ClientInputToGraph client to convert user input inquiry to the DiagramGraph.
func NewOpenAIClient ¶
func NewOpenAIClient(cfg ConfigOpenAI, optFns ...func(client *clientOpenAI)) (ClientInputToGraph, error)
NewOpenAIClient initiates the client to communicate with the plantuml server.
type ClientStorage ¶ added in v0.0.2
type ClientStorage interface { // WritePrompt writes user's input prompt. WritePrompt(ctx context.Context, v UserInput) error // WriteModelPrediction writes model's prediction result used to generate diagram. WriteModelPrediction(ctx context.Context, v ModelOutput) error // Close closes the connection. Close(ctx context.Context) error }
ClientStorage defines the client to communicate to the storage to persist core logic transactions.
type ConfigOpenAI ¶
type ConfigOpenAI struct { // https://platform.openai.com/docs/api-reference/authentication Token string // https://platform.openai.com/docs/api-reference/requesting-organization Organization string // https://platform.openai.com/docs/api-reference/completions/create#completions/create-model Model string // https://platform.openai.com/docs/api-reference/completions/create#completions/create-max_tokens MaxTokens int // https://platform.openai.com/docs/api-reference/completions/create#completions/create-temperature Temperature float32 }
ConfigOpenAI configuration of the OpenAI client. see:
type DiagramGraph ¶
type DiagramGraph struct { Title string `json:"title,omitempty"` Nodes []*Node `json:"nodes"` Links []*Link `json:"links,omitempty"` }
DiagramGraph defines the diagram graph.
type Error ¶
Error defines the core logic error to facilitate errors handling across the product elements.
type HttpClient ¶
HttpClient http base client.
type Link ¶
type Link struct { From string `json:"from"` To string `json:"to"` Direction string `json:"direction,omitempty"` Label string `json:"label,omitempty"` Technology string `json:"technology,omitempty"` }
Link diagram's definition link.
type MockClientStorage ¶ added in v0.0.2
type MockClientStorage struct {
Err error
}
func (MockClientStorage) Close ¶ added in v0.0.2
func (m MockClientStorage) Close(ctx context.Context) error
func (MockClientStorage) WriteModelPrediction ¶ added in v0.0.2
func (m MockClientStorage) WriteModelPrediction(ctx context.Context, v ModelOutput) error
func (MockClientStorage) WritePrompt ¶ added in v0.0.2
func (m MockClientStorage) WritePrompt(ctx context.Context, v UserInput) error
type ModelOutput ¶ added in v0.0.2
ModelOutput type defining the model's output.
type Node ¶
type Node struct { ID string `json:"id"` Label string `json:"label,omitempty"` Group string `json:"group,omitempty"` Technology string `json:"technology,omitempty"` External bool `json:"external,omitempty"` IsQueue bool `json:"is_queue,omitempty"` IsDatabase bool `json:"is_database,omitempty"` }
Node diagram's definition node.
type ResponseC4Diagram ¶
type ResponseC4Diagram struct {
SVG string `json:"svg"`
}
ResponseC4Diagram resulting C4 diagram.
func (ResponseC4Diagram) MustMarshal ¶
func (r ResponseC4Diagram) MustMarshal() []byte
type ResponseDiagram ¶
type ResponseDiagram interface { // MustMarshal serialises the result as JSON. MustMarshal() []byte }
ResponseDiagram response object.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package handler defines the client-server communication entrypoint handler.
|
Package handler defines the client-server communication entrypoint handler. |
secretsmanager
module
|
|
storage
module
|
|