Core
State
State refers to a current state of the pipeline. A (non-empty) state in Dingo can be an instance of either KVData
or ChatPrompt
class. We already discussed that different block types expect different types of states as input and return different types of states as output. Therefore, it is important to correctly compose the pipeline blocks to ensure that the consecutive elements are compatible with each other. For example, a PromptBuilder
block expects a ChatPrompt
as input and returns a ChatPrompt
as output, whereas a Reasoner
block expects a ChatPrompt
as input and returns a KVData
as output. This means that you can directly connect a PromptBuilder
to a Reasoner
, but not vice versa.
ChatPrompt
ChatPrompt
is a sequence of messages that represent a conversation between the user and the assistant. Each message can be a UserMessage
, AssistantMessage
, or SystemMessage
object. The UserMessage
object represents a message sent by the user, the AssistantMessage
object represents a message sent by the assistant, and the SystemMessage
represents an instruction from the system to the assistant.
from agent_dingo.core.state import ChatPrompt
from agent_dingo.core.message import UserMessage, AssistantMessage, SystemMessage
messages = [
SystemMessage("You are a helpful assustant. Answer the user's questions as clearly as possible."),
UserMessage("What is the capital of France?"),
AssistantMessage("The capital of France is Paris."),
UserMessage("How large is it?"),
]
KVData
KVData
: a key-value data object that stores arbitrary string keys and values. Usually used to store the response generated by the LLM (in this case the key is "_out_0"), but can be used for any other purpose.
Overall, KVData can be seen as a special/restricted dictionary:
from agent_dingo.core.state import KVData
data = KVData(key1="value1", key2="value2")
assert data["key1"] == "value1"
assert data["key2"] == "value2"