
NOTICE: All information contained herein is, and remains
the property of TechnoCore.
The intellectual and technical concepts contained
herein are proprietary to TechnoCore and dissemination of this information or reproduction of this material
is strictly forbidden unless prior written permission is obtained
from TechnoCore.
The ObjAiMcpOpenai class provides an interface to OpenAI's language models, such as GPT-4. It is part of the Multi-Cloud Provider (MCP) framework and inherits from the ObjAiMcpBase class.
The class is initialized with the following parameters:
def __init__(self, db=0, api_key: str = "", model: str = "gpt-4"):
db: The database connection object.api_key: Your OpenAI API key.model: The specific OpenAI model to use (e.g., "gpt-4", "gpt-3.5-turbo").promptSends a prompt to the specified OpenAI model and returns the response.
def prompt(self, role: str = "", prompt: str = "", image_base64: str = "") -> str:
role: The system role for the AI (e.g., "You are a helpful assistant.").prompt: The user's prompt or question.image_base64: A base64-encoded image for multimodal prompts.To use the OpenAI provider, you must first configure your API key in the config.yaml file under the ai_mcp_openai section.
ai_mcp_openai:
api_key: YOUR_OPENAI_API_KEY
You can then instantiate and use the ObjAI class with the appropriate model string:
ai_obj = ObjAI(db=0, model="mcp:openai:gpt-4")
response = ai_obj.prompt("You are a helpful assistant.", "What is the capital of France?")
print(response)