Store Chat Messages & State Without Managing Infrastructure.Check Out DialogueDB
Skip to content

Dialogue

Internally, state uses the Dialogue class to manage dialogues, and you can use it independently too if you'd like.

ts
const chatHistory = createDialogue("chat")
.setUserMessage("Hey anyone there?")
.setAssistantMessage("Yep! Whats up?")

const history = chatHistory.getHistory()
[
  {
    "role": "user",
    "content": "Hey anyone there?"
  },
  {
    "role": "assistant",
    "content": "Yep! Whats up?"
  }
]
ts
const function_call = {
  name: "get_weather",
  arguments: '{"city": "Cleveland"}',
};
  
const chatHistory = createDialogue("chat")
.setUserMessage("What is the weather in Cleveland?")
.setFunctionCallMessage({ function_call })
.setFunctionMessage('{ "weather": "Cold, rainy" }', "get_weather")
.setAssistantMessage("Looks like normal weather in Cleveland");

const history = chatHistory.getHistory()
[
  {
    "role": "user",
    "content": "What is the weather in Cleveland?"
  },
  {
    "role": "function_call",
    "function_call": {
      "name": "get_weather",
      "arguments": "{\"city\": \"Cleveland\"}"
    },
    "content": null
  },
  {
    "role": "function",
    "name": "get_weather",
    "content": "{ \"weather\": \"Cold, rainy\" }"
  },
  {
    "role": "assistant",
    "content": "Looks like normal weather in Cleveland"
  }
]