Split character from state

This commit is contained in:
mudler
2024-04-03 18:04:50 +02:00
parent a404b75fbe
commit e6090c62cf
7 changed files with 261 additions and 249 deletions

View File

@@ -12,20 +12,34 @@ import (
// all information that should be displayed to the LLM
// in the prompts
type PromptHUD struct {
Character Character `json:"character"`
Character Character `json:"character"`
CurrentState State `json:"current_state"`
}
type Character struct {
Name string `json:"name"`
Age int `json:"age"`
Occupation string `json:"job_occupation"`
// State is the structure
// that is used to keep track of the current state
// and the Agent's short memory that it can update
// Besides a long term memory that is accessible by the agent (With vector database),
// And a context memory (that is always powered by a vector database),
// this memory is the shorter one that the LLM keeps across conversation and across its
// reasoning process's and life time.
// A special action is then used to let the LLM itself update its memory
// periodically during self-processing, and the same action is ALSO exposed
// during the conversation to let the user put for example, a new goal to the agent.
type State struct {
NowDoing string `json:"doing_now"`
DoingNext string `json:"doing_next"`
DoneHistory []string `json:"done_history"`
Memories []string `json:"memories"`
Hobbies []string `json:"hobbies"`
MusicTaste []string `json:"music_taste"`
Sex string `json:"sex"`
}
type Character struct {
Name string `json:"name"`
Age int `json:"age"`
Occupation string `json:"job_occupation"`
Hobbies []string `json:"hobbies"`
MusicTaste []string `json:"music_taste"`
Sex string `json:"sex"`
}
func Load(path string) (*Character, error) {
@@ -69,10 +83,6 @@ func (a *Agent) validCharacter() bool {
return a.Character.Name != "" &&
a.Character.Age != 0 &&
a.Character.Occupation != "" &&
a.Character.NowDoing != "" &&
a.Character.DoingNext != "" &&
len(a.Character.DoneHistory) != 0 &&
len(a.Character.Memories) != 0 &&
len(a.Character.Hobbies) != 0 &&
len(a.Character.MusicTaste) != 0
}
@@ -81,10 +91,6 @@ const fmtT = `=====================
Name: %s
Age: %d
Occupation: %s
Now doing: %s
Doing next: %s
Done history: %v
Memories: %v
Hobbies: %v
Music taste: %v
=====================`
@@ -95,10 +101,6 @@ func (a *Agent) String() string {
a.Character.Name,
a.Character.Age,
a.Character.Occupation,
a.Character.NowDoing,
a.Character.DoingNext,
a.Character.DoneHistory,
a.Character.Memories,
a.Character.Hobbies,
a.Character.MusicTaste,
)