Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Explodinggradients Ragas OCIGenAIWrapper Class

From Leeroopedia


Knowledge Sources
Domains LLM, Oracle_Cloud
Last Updated 2026-02-10 00:00 GMT

Overview

Direct integration wrapper for Oracle Cloud Infrastructure (OCI) Generative AI services implementing the Ragas LLM interface.

Description

OCIGenAIWrapper extends BaseRagasLLM to provide text generation using OCI Generative AI services. It supports both sync and async generation, role-aware message conversion, and lazy client initialization. A factory function oci_genai_factory provides convenient instantiation.

Usage

Use this wrapper when running Ragas evaluations with Oracle Cloud's Generative AI models.

Code Reference

Source Location

Signature

class OCIGenAIWrapper(BaseRagasLLM):
    def __init__(
        self,
        model_id: str,
        compartment_id: str,
        config: Optional[Dict] = None,
        endpoint_id: Optional[str] = None,
        run_config: Optional[RunConfig] = None,
        cache: Optional[Any] = None,
        default_system_prompt: Optional[str] = None,
        client: Optional[Any] = None,
    ):
        ...
    def generate_text(self, prompt: PromptValue, n: int = 1, temperature: Optional[float] = None, stop: Optional[List[str]] = None, callbacks: Optional[Any] = None) -> LLMResult:
        ...
    async def agenerate_text(self, prompt: PromptValue, n: int = 1, temperature: Optional[float] = None, stop: Optional[List[str]] = None, callbacks: Optional[Any] = None) -> LLMResult:
        ...

def oci_genai_factory(model_id: str, compartment_id: str, ...) -> OCIGenAIWrapper:
    ...

Import

from ragas.llms.oci_genai_wrapper import OCIGenAIWrapper, oci_genai_factory

I/O Contract

Inputs

Name Type Required Description
model_id str Yes OCI model identifier
compartment_id str Yes OCI compartment OCID
config Optional[Dict] No OCI SDK configuration
prompt PromptValue Yes LangChain prompt value to generate from

Outputs

Name Type Description
generate_text returns LLMResult Generated text with metadata
agenerate_text returns LLMResult Async generated text with metadata

Usage Examples

from ragas.llms.oci_genai_wrapper import oci_genai_factory

llm = oci_genai_factory(
    model_id="cohere.command-r-plus",
    compartment_id="ocid1.compartment.oc1...",
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment