Skip to content

Instantly share code, notes, and snippets.

@Zetaphor
Zetaphor / chainforge_openai_compatible_provider.py
Created January 2, 2025 19:34
Chainforge - OpenAI Compatible API Provider
from chainforge.providers import provider
import openai
from typing import Optional, Any, List, Dict, Union
# Define ChatHistory type locally
ChatMessage = Dict[str, str] # {"role": str, "content": str}
ChatHistory = List[ChatMessage]
# Schema for provider settings
OPENAI_COMPATIBLE_SETTINGS_SCHEMA = {