Skip to content

AI

Actions to assist in AI calls.


Actions

openai_gpt

Send requests to the Marvin assistant using the OpenAI-compatible API implemented in the code.

Parameters:
  • model_name: str
  • api_key: str
  • instructions: str
  • content: str
  • files: list = None
  • file_name: str = None
  • file_path: str = None
Return:
  • chatbot_response — assistant response (text or list as in code).
  • file_path — when a Word file is generated, full path to the file (optional).
Exceptions:
  • UnsupportedMidiaType — unsupported media type.
  • Exception — general errors during processing/files/assistant.

Minimal example:

openai_gpt("gpt-4o", "API_KEY", "Analyze these data", "My content here", files=None)
chatbot_response = $chatbot_response


langchain_openai

LangChain wrapper action for supported models (parameters and returns follow the code).

Parameters:
  • model_name: str
  • messages: list
  • api_key: str
  • temperature: float = 0
  • file_path: str = None
  • file_name: str = None
Return:
  • chatbot_response — response returned by the model (text).
  • file_path — when applicable, path to the generated Word document.
Exceptions:
  • UnsupportedModelException — when model_name is not in the supported list.
  • UnsupportedMidiaType — when messages include unsupported media.
  • Exception — general errors.

Minimal example:

messages = [
    {"type": "SYSTEM", "content": "Instructions"},
    {"type": "HUMAN", "content": "User question"}
]
langchain_openai("gpt-3.5-turbo", messages, "API_KEY")
chatbot_response = $chatbot_response


ia.langchain_openai

Invokes a chat model through LangChain (ChatOpenAI for GPT models). Builds the prompt from a messages list that may include system text, human text, and media entries.

Parameters:

model_name - model id; must be one of: gpt-3.5-turbo, gpt-4o, gemini-pro, gemini-pro-vision.

messages - list of message dicts. Supported type values: SYSTEM, HUMAN, MIDIA. For MIDIA, content_type may be PDF, IMAGE, or other types supported by the action (see code mapping).

api_key - API key (used as OPENAI_API_KEY for GPT models).

temperature (optional) - sampling temperature (default=0).

file_path (optional) - folder to write a Word document with the response (default=None).

file_name (optional) - Word file name when file_path is set (default=None).

Return:

chatbot_response - model response text (response.content).

file_path (optional) - path to the generated Word file when file_path is provided.

Exceptions:

UnsupportedModelException: when model_name is not in the supported list.

UnsupportedMidiaType: when a MIDIA entry uses an unsupported content_type.

Exception: on image OCR or file parsing errors.

Usage example
script.mvn
messages = [
    {"type": "SYSTEM", "content": "You are a helpful assistant."},
    {"type": "HUMAN", "content": "Explain this process."}
]
ia.langchain_openai("gpt-4o", messages, $api_key)
prompt.alert($chatbot_response)

ia.openai_gpt

Calls the Marvin assistant using the OpenAI Python client. Supports optional file attachments (documents and images) and optional Word document output.

Parameters:

model_name - OpenAI model name (for example gpt-4o).

api_key - OpenAI API key.

instructions - system/instruction text for the assistant.

content - user prompt or main content.

files (optional) - list of file paths to attach; extensions must be in the supported set used by the action (PDF, Office formats, images, CSV, JSON, etc.) (default=None).

file_name (optional) - output Word file name when generating a document (default=None).

file_path (optional) - output folder path when generating a Word document; both file_path and a file in files must be set for document export (default=None).

Return:

chatbot_response - assistant response (format as returned by the internal assistant wrapper).

file_path (optional) - full path to the generated Word file when export is requested.

Exceptions:

UnsupportedMidiaType: when an attached file extension is not supported.

Exception: on assistant errors, file processing failures, or invalid assistant status.

Usage example
script.mvn
ia.openai_gpt("gpt-4o", $api_key, "Summarize the report", "Please summarize", files=None)
prompt.alert(str($chatbot_response))