langsmithgo

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: GPL-3.0 Imports: 10 Imported by: 7

README

langsmithgo

LangSmithGo is a Golang-based client library designed to interface with the LangSmith API for tracking and monitoring large language model (LLM) applications. Its primary objective is to offer Go developers a streamlined pathway for integrating LangSmith's tracing capabilities within their production systems

Documentation

Index

Constants

View Source
const (
	BASE_URL = "https://api.smith.langchain.com/api/v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	APIKey string // API key for LangSmith
	// contains filtered or unexported fields
}

func NewClient

func NewClient() (*Client, error)

NewClient creates a new LangSmith client The client requires an API key to authenticate requests. You can get an API key by signing up for a LangSmith account at https://smith.langchain.com The API key can be passed as an argument to the function or set as an environment variable LANGSMITH_API_KEY

func (*Client) Do

func (c *Client) Do(url string, method string, jsonData []byte) error

client for http requests

func (*Client) PatchRun

func (c *Client) PatchRun(id string, input *RunPayload) error

func (*Client) PostRun

func (c *Client) PostRun(input *RunPayload) error

func (*Client) Run

func (c *Client) Run(input *RunPayload) error

func (*Client) RunSingle

func (c *Client) RunSingle(input *RunPayload) error

type Event

type Event struct {
	EventName string `json:"event_name"`
	Reason    string `json:"reason,omitempty"`
	Value     string `json:"value,omitempty"`
}

type PatchPayload

type PatchPayload struct {
	Outputs map[string]interface{} `json:"outputs"`
	EndTime time.Time              `json:"end_time"`
	Events  []Event                `json:"events,omitempty"`
}

type PostPayload

type PostPayload struct {
	ID          string                 `json:"id"`
	Name        string                 `json:"name"`
	RunType     RunType                `json:"run_type"`
	StartTime   time.Time              `json:"start_time"`
	Inputs      map[string]interface{} `json:"inputs"`
	SessionName string                 `json:"session_name"`
	Tags        []string               `json:"tags,omitempty"`
	ParentId    string                 `json:"parent_run_id,omitempty"`
	Extras      map[string]interface{} `json:"extra,omitempty"`
	Events      []Event                `json:"events,omitempty"`
}

type Response

type Response struct {
	Detail string `json:"detail"`
}

type RunPayload

type RunPayload struct {
	RunID       string                 `json:"id"`
	Name        string                 `json:"name"`
	RunType     RunType                `json:"run_type"`
	StartTime   time.Time              `json:"start_time"`
	Inputs      map[string]interface{} `json:"inputs"`
	ParentID    string                 `json:"parent_run_id"`
	SessionName string                 `json:"session_name"`
	Tags        []string               `json:"tags"`
	Outputs     map[string]interface{} `json:"outputs"`
	EndTime     time.Time              `json:"end_time"`
	Extras      map[string]interface{} `json:"extra"`
	Events      []Event                `json:"events"`
}

type RunType

type RunType int
const (
	Tool RunType = iota
	Chain
	LLM
	Retriever
	Embedding
	Prompt
	Parser
)

Enum values using iota

func (RunType) MarshalJSON

func (r RunType) MarshalJSON() ([]byte, error)

MarshalJSON customizes the JSON output for RunType

func (RunType) String

func (r RunType) String() string

String returns the string representation of the RunType

type SimplePayload

type SimplePayload struct {
	ID          string                 `json:"id"`
	Name        string                 `json:"name"`
	RunType     RunType                `json:"run_type"`
	StartTime   time.Time              `json:"start_time"`
	Inputs      map[string]interface{} `json:"inputs"`
	SessionName string                 `json:"session_name"`
	Tags        []string               `json:"tags,omitempty"`
	ParentId    string                 `json:"parent_run_id,omitempty"`
	Extras      map[string]interface{} `json:"extra,omitempty"`
	Events      []Event                `json:"events,omitempty"`
	Outputs     map[string]interface{} `json:"outputs"`
	EndTime     time.Time              `json:"end_time"`
}

Jump to

Keyboard shortcuts

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