Prepare requests with captured conversation history
This commit is contained in:
29
exchange.go
Normal file
29
exchange.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package promptkit
|
||||
|
||||
import "go.maximumdirect.net/promptkit/internal/domain"
|
||||
|
||||
const exchangeString = "promptkit.Exchange{opaque}"
|
||||
|
||||
// Exchange is an immutable, in-process snapshot of a completed conversation.
|
||||
type Exchange struct{ internal *domain.Exchange }
|
||||
|
||||
// ExchangeDetails contains a detached copy of an exchange's logical history.
|
||||
type ExchangeDetails struct {
|
||||
RunID string `json:"run_id"`
|
||||
ParentRunID string `json:"parent_run_id,omitempty"`
|
||||
Messages []RenderedMessage `json:"messages"`
|
||||
}
|
||||
|
||||
// Details returns detached history, or zero details for an empty handle.
|
||||
func (e *Exchange) Details() ExchangeDetails {
|
||||
if e == nil || e.internal == nil {
|
||||
return ExchangeDetails{}
|
||||
}
|
||||
return ExchangeDetails{RunID: e.internal.RunID(), ParentRunID: e.internal.ParentRunID(), Messages: fromDomainRenderedMessages(e.internal.Messages())}
|
||||
}
|
||||
|
||||
// String returns an opaque representation without conversation content.
|
||||
func (e Exchange) String() string { return exchangeString }
|
||||
|
||||
// GoString returns an opaque representation without conversation content.
|
||||
func (e Exchange) GoString() string { return exchangeString }
|
||||
Reference in New Issue
Block a user