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 Matplotlib graph from a given prompt.
# 📦 Package: morph_lib.ai.openai.code_generation
# 🛠️ Function: text_to_matplotlib
def text_to_matplotlib(
prompt: str,
api_key: str,
table_names: List[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.
API key to use the LLM model
List of table names to use for generation
Example
from morph_lib.ai.openai import text_to_matplotlib
import os
@morph.func
def func_name(context):
fig = text_to_matplotlib(
prompt,
os.environ["OPENAI_API_KEY"],
["user"],
"gpt-4o",
)
code = fig.code
print(code)
return fig.content