Skip to content

Commit

Permalink
Merge pull request #19 from getzep/v2
Browse files Browse the repository at this point in the history
Fix MemoryType Enums
  • Loading branch information
paul-paliychuk authored Jun 19, 2024
2 parents 3bb1051 + 26695c6 commit 9f76dca
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
31 changes: 1 addition & 30 deletions memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

package zep

import (
fmt "fmt"
)

type AddMemoryRequest struct {
// Additional instruction for generating the facts.
FactInstruction *string `json:"fact_instruction,omitempty" url:"fact_instruction,omitempty"`
Expand Down Expand Up @@ -48,7 +44,7 @@ type ExtractDataRequest struct {

type MemoryGetRequest struct {
// The type of memory to retrieve: perpetual, summary_retriever, or message_window. Defaults to perpetual.
MemoryType *MemoryGetRequestMemoryType `json:"-" url:"memoryType,omitempty"`
MemoryType *MemoryType `json:"-" url:"memoryType,omitempty"`
// The number of most recent memory entries to retrieve.
Lastn *int `json:"-" url:"lastn,omitempty"`
}
Expand Down Expand Up @@ -103,31 +99,6 @@ type MemorySynthesizeQuestionRequest struct {
LastNMessages *int `json:"-" url:"lastNMessages,omitempty"`
}

type MemoryGetRequestMemoryType string

const (
MemoryGetRequestMemoryTypePerpetual MemoryGetRequestMemoryType = "perpetual"
MemoryGetRequestMemoryTypeSummaryRetriever MemoryGetRequestMemoryType = "summary_retriever"
MemoryGetRequestMemoryTypeMessageWindow MemoryGetRequestMemoryType = "message_window"
)

func NewMemoryGetRequestMemoryTypeFromString(s string) (MemoryGetRequestMemoryType, error) {
switch s {
case "perpetual":
return MemoryGetRequestMemoryTypePerpetual, nil
case "summary_retriever":
return MemoryGetRequestMemoryTypeSummaryRetriever, nil
case "message_window":
return MemoryGetRequestMemoryTypeMessageWindow, nil
}
var t MemoryGetRequestMemoryType
return "", fmt.Errorf("%s is not a valid %T", s, t)
}

func (m MemoryGetRequestMemoryType) Ptr() *MemoryGetRequestMemoryType {
return &m
}

type ModelsMessageMetadataUpdate struct {
// The metadata to update
Metadata map[string]interface{} `json:"metadata,omitempty" url:"metadata,omitempty"`
Expand Down
25 changes: 25 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,31 @@ func (m *MemorySearchResult) String() string {
return fmt.Sprintf("%#v", m)
}

type MemoryType string

const (
MemoryTypePerpetual MemoryType = "perpetual"
MemoryTypeSummaryRetriever MemoryType = "summary_retriever"
MemoryTypeMessageWindow MemoryType = "message_window"
)

func NewMemoryTypeFromString(s string) (MemoryType, error) {
switch s {
case "perpetual":
return MemoryTypePerpetual, nil
case "summary_retriever":
return MemoryTypeSummaryRetriever, nil
case "message_window":
return MemoryTypeMessageWindow, nil
}
var t MemoryType
return "", fmt.Errorf("%s is not a valid %T", s, t)
}

func (m MemoryType) Ptr() *MemoryType {
return &m
}

type Message struct {
// The content of the message.
Content *string `json:"content,omitempty" url:"content,omitempty"`
Expand Down

0 comments on commit 9f76dca

Please sign in to comment.