Generators

AI, GPT, and more

Generators are a class of event that produce values, whether that be numbers (e.g. Source) or text (e.g. Ai).

AI

The Ai event calls a specified model:

=Ai("gpt-4o", "{{ OPENAI_KEY}}")

To send a prompt and other configuration options to this event, we use an Object:

=Object({"prompt": [{"role": "system", "content": "You are an intelligent, helpful assistant."}, {"role": "user", "content": "Why do people love Austin, TX? Be honest and concise."}]})

The event will return a JSON object for use downstream. This object will include a raw attribute as well as the result of parsing this raw (markdown) content into blocks: text, code, links, and images. For example, if the response includes a JSON block, you will be able to find that JSON under the code block and refer to it using a path like so:

{{ my_ai_event.content[0].blocks.code[0].source }}

If the code is JSON, the object itself will be indexable, for example:

{{ my_ai_event.content[0].blocks.code[0].source.invoice.total }}

In most cases, this makes a subsequent parsing step following the Ai call unnecessary.

Supported models

ModelDescription
gpt-4oFaster and cheaper than GPT-4 Turbo with stronger vision capabilities.
gpt-4Broad general knowledge and domain expertise.
gpt-4-turbo128K context with an April 2023 knowledge cutoff and basic support for vision.
gpt-3.5-turbo-0125Fast and inexpensive model for simple tasks.
llama3 (experimental)Openly accessible model that excels at language.
pdfUse PDF.ai's fine-tuned model for handling and parsing large PDF files.

🚧

llama3

We are still working on support for the llama3 model and are eager for testers familiar with the model. If that's you, let us know!

Search

A Search generates a response by calling Tavily's Search API and serving up the results as an object for you to pass downstream.

=Search("When will Mariah Carey want us to start playing Christmas music this year?")

This search is designed for use prior to an Ai call, as the content can be used to augment the understanding of the AI / LLM with current news, information, or otherwise special knowledge.

The response will include a best attempt at "the answer", along with up to 5 sources of information with URL's and content snippets.

You can send keyword arguments (options) to the Search event by passing it an Object:

=Object({"search_depth": "advanced"
         "max_results": 5,
         "include_answer": true,
         "include_raw_content": false,
         "include_domains": ["lookhere.com", "andalsohere.org"],
         "exclude_domains": ["ignorethisone.xyz"],
         "cache_duration": 60
})

Note that the include_domains option will restrict searching to those domains only.

πŸ’‘

Search + Text

Consider placing a Text event immediately after a Search event in order to compose the output of the search into a nice block of text for injecting into a prompt.

News & Maps

You may also search Google News and Google Maps by passing in a second argument to your search event:

=Search("best pizza in Austin, TX", "maps")

This will return a list of up to 20 pizza places in Austin, Texas using Google Maps.

=Search("best new pizza places in Austin, TX", "news")

This will return up to 20 news articles from Google News that mention developments in the pizzeria space in central Texas.

Source

A Source generates numerical values to sent to other events. A good example is a revenue source. If my business earns $100,000 per month, growing at 3% per month, I could use a SEL formula to represent this income stream like so:

=Source(100k @ 3%)

πŸ“˜

Source or List

The benefit of using a Source over a list is the ability to attach a growth rate. Lists may only contain constants (unchanging) values, whereas the values returned from a Source can change over time using a growth rate, or a list of growth rates.

This event will send a steady stream of one hundred thousand (growing at 3%) to downstream events.

Maximum Values

Sources can also take a second argument, used to set a maximum value. For example:

=Source(100k @ 3%, 110k)

This will grow 100,000 by 3% until it reaches 110,000. At this point, it will consistently send 110,000.

If you send a value to a source, the size of the source will increase by the received value. This means you can simulate a pay increase, for example, by having an annually recurring event send a raise amount to a monthly salary source.

There's a second way to express a maximum value for a source, which can also take a minimum value -- the spread operator: ....

=Source(100k...110k @ 3%)

Will grow 100,000 by 3% per occurrence until 110,000 is reached, then repeat 110,000.

=Source(100k...90k @ -10%)

Will decrease 100,000 to 90,000 in increments of -10%.

This also works with negative values:

=Source(-2k...-5k @ 10%)

Will "grow" -2,000 by 10% per occurrence to a minimum of -5,000.

Curve

The Curve event generates values along a specified curve, like so:

=Curve('s', [365, 1k])

The first argument is the type of curve. The supported curve types are s (S-curve) and m (straight line or linear). The second argument is a list where the first value (365) represents the number of days until the maximum value is reached. The maximum value is defined by an optional second element in the list, here 1k (1,000). If the maximum is omitted, the maximum will default to 1.

Most growth in nature and business follows an S-curve (short for sigmoid). That makes this event especially useful for modeling the growth of almost anything, especially when a precise mathematical model (i.e. growth rates) is unknown.

Trend

Like a source, a Trend generates a series of values that are sent downstream to other events. But unlike a source, rather than taking an initial value and optional growth rate, a Trend takes a series of historical values:

=Trend([12.1k,15.5k,13.6k,14.4k])

Summit will fit a trendline to this series of values and return the values in the sequence, in this case: 15,150, 15,650, 16,150, 16,650, ...

🚧

What's in a trend?

True to its name, a trend is just a trend. The purpose of a trend is directionality. Therefore, this source of values is useful when historical values bounce around, and the most important element is understanding the general movement of these values, rather than the specific value in any given future month.

Extend

The Extend event takes a series of values and extends them using the last two values in the sequence. For example:

=Extend([1,2,3,10])

Will return 17, 24, 31, 38 ... because the slope of the final two items is 7.

The extend event is useful for drawing a straight line when the most recent values are an indication of the future.

GPT

🚧

Deprecated

This event type has been replaced by the Ai event. This documentation will remain here temporarily to help with revisions. New models should use the Ai event.

The Gpt event takes a prompt object as input and returns the content of the response from OpenAI's ChatGPT. You call it by specifying the model you wish to use and providing a key to authorize usage using liquid syntax to refer to the key in your Vault:

=Gpt('gpt-4-turbo', '{{ MY_OPENAI_KEY }}')

❗️

API key security

For security, the key should be stored in your Vault, not placed into the call as text.

An example of a valid prompt object:

=Object({"prompt": [{"role": "system", "content": "You are an intelligent, helpful assistant."}, {"role": "user", "content": "Why do people love Austin, TX? Be honest and concise."}]})


What’s Next

Now that you know how and when to use a Generator, let's learn about Containers -- events that manage the flow of value within your model.