Building the Backend
In Morph, you build the backend using Python. You can freely add Python packages to build data processing and AI workflows.
Development Flow
The steps for backend development in Morph are as follows.
Add Python Packages
Since Morph follows the common Python project format, you can freely add Python packages. Add the necessary packages to requirements.txt
or poetry.toml
.
Define Python Functions and Add Morph Decorators
By adding Morph decorators to regular Python function definitions, you can set aliases. This allows you to reference the results of these functions from other Python, SQL, or Markdown files.
Test Python Functions
Use the morph run
command to execute functions for unit testing.
Start the Development Server
By starting the development server, you can check the web application locally.
Return Values of Python Functions
Python functions defined in a Morph project should have the following return values.
DataFrame
A DataFrame object representing the result of data processing. SQL execution results are also handled as DataFrames. Use this when you want to use the result of data processing in other Python files or display it in Markdown files.
The corresponding Markdown component is <DataFrame>
.
HTML String
An HTML string for rendering the results of data visualization. Use this when you want to display graphs drawn using visualization libraries like Plotly or Bokeh.
The corresponding Markdown component is <Embed>
.
Streaming
Use this when using streaming APIs such as LLM API. Execute value streaming using the stream_chat
function.
The corresponding Markdown component is <Chat>
.