praval.providers.openai๏ƒ

OpenAI provider implementation for Praval framework.

Provides integration with OpenAIโ€™s Chat Completions API with support for conversation history, tool calling, and streaming responses.

Classes

OpenAIProvider(config)

OpenAI provider for LLM interactions.

class praval.providers.openai.OpenAIProvider(config)[source]๏ƒ

Bases: object

OpenAI provider for LLM interactions.

Handles communication with OpenAIโ€™s GPT models through the Chat Completions API with support for tools and conversation history.

__init__(config)[source]๏ƒ

Initialize OpenAI provider.

Parameters:

config โ€“ AgentConfig object with provider settings

Raises:

ProviderError โ€“ If OpenAI client initialization fails

generate(messages, tools=None)[source]๏ƒ

Generate a response using OpenAIโ€™s Chat Completions API.

Parameters:
  • messages (List[Dict[str, str]]) โ€“ Conversation history as list of message dictionaries

  • tools (Optional[List[Dict[str, Any]]]) โ€“ Optional list of available tools for function calling

Return type:

str

Returns:

Generated response as a string

Raises:

ProviderError โ€“ If API call fails