Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions guardrails/guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from langchain_core.messages import BaseMessage
from langchain_core.runnables import Runnable, RunnableConfig
from pydantic import BaseModel
from pydantic.version import VERSION as PYDANTIC_VERSION
from typing_extensions import deprecated

from guardrails.api_client import GuardrailsApiClient
Expand Down Expand Up @@ -369,6 +370,13 @@ def from_pydantic(
description: Optional[str] = None,
):
"""Create a Guard instance from a Pydantic model and prompt."""
if PYDANTIC_VERSION.startswith("1"):
warnings.warn(
"""Support for Pydantic v1.x is deprecated and will be removed in
Guardrails 0.5.x. Please upgrade to the latest Pydantic v2.x to
continue receiving future updates and support.""",
FutureWarning,
)
# We have to set the tracer in the ContextStore before the Rail,
# and therefore the Validators, are initialized
cls._set_tracer(cls, tracer) # type: ignore
Expand Down
15 changes: 15 additions & 0 deletions guardrails/utils/openai_utils/v0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, AsyncIterable, Dict, Iterable, List, cast
from warnings import warn

import openai
import openai.error
Expand All @@ -15,19 +16,33 @@
)


def raise_v0_deprecation_warning():
"""Raise a warning about support deprecation for OpenAI v0.x."""
warn(
"""Support for OpenAI v0.x is deprecated and will be removed in
Guardrails 0.5.x. Please upgrade to the latest OpenAI v1.x to
continue receiving future updates and support.""",
FutureWarning,
)


def get_static_openai_create_func():
raise_v0_deprecation_warning()
return openai.Completion.create


def get_static_openai_chat_create_func():
raise_v0_deprecation_warning()
return openai.ChatCompletion.create


def get_static_openai_acreate_func():
raise_v0_deprecation_warning()
return openai.Completion.acreate


def get_static_openai_chat_acreate_func():
raise_v0_deprecation_warning()
return openai.ChatCompletion.acreate


Expand Down