The morph_lib.ai package has been deprecated since v0.1.5 to reduce the size of the morph-data package.

It is planned to be provided in the form of an external adapter in the future.

Generates a Markdown from a given prompt.

# 📦 Package: morph_lib.ai.openai.code_generation
# 🛠️ Function: text_to_markdown

def text_to_markdown(
    prompt: str,
    api_key: str,
    model: Optional[str] = "gpt-4o",
) -> TextConversionResponse:

Parameters

These are the parameters for OpenAI. Please set the authentication parameters for other models as appropriate from the function definitions above.

prompt
string
required

Prompt

api_key
string
required

API key to use the LLM model

model
string

LLM model to use

Example

from morph_lib.ai.openai.code_generation import text_to_markdown
import os

@morph.func
def func_name(context):
    prompt = context.vars["prompt"]
    fig = text_to_markdown(
		prompt,
		os.environ["OPENAI_API_KEY"],
		"gpt-4o",
	)
	code = fig.code
	print(code)

	return fig.content