- Getting Started
- Simple Nodes
- A prompt node generating an inspirational quote
- Declaring another prompt that is dependent on the result of InspirationalQuote
- Example of authoring the query for the node to subscribe to InspirationalQuote explicitly
- Capturing the output of the system
Getting Started
Simple Nodes
A prompt node generating an inspirational quote
Individually, nodes with no queries run once at the beginning of execution, their results can be read or consumed by other nodes.
quote = await self.client.prompt_node(
name="InspirationalQuote",
template="""
Come up with a novel and interesting quote.
Something that will make them. want to seize the day.
""")
Declaring another prompt that is dependent on the result of InspirationalQuote
There are a couple ways to feed data into another node, the most simple is to use the run_when
method on a node. This updates the node’s queries so that it will execute whenever the provided node has available changes.
translate_to_spanish = await self.client.prompt_node(
name="SpanishTranslation",
template="""
Translate the following to spanish: {{promptResult}}
""")
translate_to_spanish.run_when(quote)
Example of authoring the query for the node to subscribe to InspirationalQuote explicitly
An alternative to this is to explicitly provide a query to the node. This is functionally identical to the resulting state of the above.
translate_to_spanish = await self.client.prompt_node(
name="SpanishTranslation",
queries=["""
query Q { InspirationalQuote { promptResult }
"""],
template="""
Translate the following to spanish: {{promptResult}}
""")
run_when
Capturing the output of the system
A system of agents that you can’t inspect or integrate with would be pretty useless. The query method can be used to inspect the state of a record at a point in time
self.client.query("""
query Q { SpanishTranslation { promptResult } }
""", 0, 0)