pm4py.llm.openai_query#

pm4py.llm.openai_query(prompt: str, api_key: str | None = None, openai_model: str | None = None, api_url: str | None = None, **kwargs) str[source]#

Executes the provided prompt, obtaining the answer from the OpenAI APIs.

Return type:

str

Parameters:
  • prompt (str) – The prompt to be executed.

  • api_key – (Optional) OpenAI API key.

  • openai_model – (Optional) OpenAI model to be used (default: “gpt-3.5-turbo”).

  • api_url – (Optional) OpenAI API URL.

  • **kwargs

    Additional parameters to pass to the OpenAI API.

Returns:

The response from the OpenAI API as a string.

import pm4py

resp = pm4py.llm.openai_query('What is the result of 3+3?', api_key="sk-382393", openai_model="gpt-3.5-turbo")
print(resp)