Module oci_genai
Module oci_genai
Generated from cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker.
Built-in codec for the Oracle Cloud Infrastructure (OCI) Generative AI chat API.
Implements LlmCodec (request decode/encode) and LlmResponseCodec (response decode) for the OCI Generative AI chat format.
OCI-specific patterns handled
- ChatDetails envelope: Requests may arrive as a full envelope (
compartmentId,servingMode,chatRequest) or as a barechatRequestpayload; both are accepted and the envelope is preserved on encode. - API formats selected by
apiFormat:GENERIC: OpenAI-stylemessageswith UPPERCASE roles (USER/ASSISTANT/SYSTEM/TOOL) whosecontentis a list of typed parts ({"type": "TEXT", "text": ...}), flattoolCalls({id, type: "FUNCTION", name, arguments}), andtoolCallIdon tool messages. Used by Meta Llama, Google, xAI, OpenAI, and imported open-weights models hosted on dedicated AI clusters.COHERE: a singlemessagestring pluschatHistoryturns withUSER/CHATBOT/SYSTEMroles and an optionalpreambleOverride. Used by Cohere Command models.COHEREV2: responses are a single assistantmessagewith typed content parts and nestedfunctiontool calls, per the OCICohereChatResponseV2schema. Requests follow the GENERICmessagespath with COHERE-stylestopSequences; V2-only request fields the normalized shape does not model (citationOptions,documents, …) ride along inextraand survive edits untouched. - Model identity: Carried in
servingMode.modelId(on-demand) orservingMode.endpointId(dedicated), not in the chat request body. - Responses:
ChatResultpayloads (modelId,chatResponse);usagecounters arepromptTokens/completionTokens/totalTokens. - Unmodeled fields are preserved: envelope and chat-response fields the normalized shape does not model (
timeCreated, future provider fields) are carried inextrarather than discarded, consistent with the other response codecs. Unmodeled fields of the decoded choice and assistant message -logprobs,serviceTier,groundingMetadata,reasoningContent,refusal(GENERIC) andtoolPlan,citations(COHEREV2) per the OCI schema - are namespaced inextraunder"choice"and"message".
The codec accepts the REST wire format only: camelCase keys, as documented in the OCI API reference. Alternate renderings produced by Oracle tooling (the CLI’s kebab-case data envelope, oci.util.to_dict() snake_case dicts) are the caller’s responsibility to convert.
Structs
- OCIGenAIChatCodec: Built-in codec for the OCI Generative AI chat API.
- OCIGenAIStreamingCodec: Streaming counterpart to
OCIGenAIChatCodec.