Python Documentation

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.
    """)
Creating a prompt node that generates an inspirational quote, once.

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)
Translate other prompts to Spanish

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}}
    """)
Translate other prompts to Spanish, but using an explicit query rather than 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)
Querying the state of a query at a particular point in execution: (0,0).