97e91a83f3
Ruff / Ruff (push) Has been cancelled
Test / Core Tests (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.10) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.11) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.12) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.13) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.9) (push) Has been cancelled
Test / Full Coverage (Python 3.11) (push) Has been cancelled
Test / Core Provider Tests (OpenAI) (push) Has been cancelled
Test / Core Provider Tests (Anthropic) (push) Has been cancelled
Test / Core Provider Tests (Google) (push) Has been cancelled
Test / Core Provider Tests (Other) (push) Has been cancelled
Test / Anthropic Tests (push) Has been cancelled
Test / Gemini Tests (push) Has been cancelled
Test / Google GenAI Tests (push) Has been cancelled
Test / Vertex AI Tests (push) Has been cancelled
Test / OpenAI Tests (push) Has been cancelled
Test / Writer Tests (push) Has been cancelled
Test / Auto Client Tests (push) Has been cancelled
ty / type-check (push) Has been cancelled
52 lines
1.1 KiB
Python
52 lines
1.1 KiB
Python
"""v2 Perplexity client factory."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, overload
|
|
|
|
import openai
|
|
|
|
from instructor.v2.core.client import AsyncInstructor, Instructor
|
|
from instructor.v2.core.mode import Mode
|
|
from instructor.v2.core.providers import Provider
|
|
from instructor.v2.providers.openai.client import _from_openai_compat
|
|
|
|
# Ensure handlers are registered.
|
|
from instructor.v2.providers.perplexity import handlers # noqa: F401
|
|
|
|
|
|
@overload
|
|
def from_perplexity(
|
|
client: openai.OpenAI,
|
|
mode: Mode = Mode.MD_JSON,
|
|
model: str | None = None,
|
|
**kwargs: Any,
|
|
) -> Instructor: ...
|
|
|
|
|
|
@overload
|
|
def from_perplexity(
|
|
client: openai.AsyncOpenAI,
|
|
mode: Mode = Mode.MD_JSON,
|
|
model: str | None = None,
|
|
**kwargs: Any,
|
|
) -> AsyncInstructor: ...
|
|
|
|
|
|
def from_perplexity(
|
|
client: openai.OpenAI | openai.AsyncOpenAI,
|
|
mode: Mode = Mode.MD_JSON,
|
|
model: str | None = None,
|
|
**kwargs: Any,
|
|
) -> Instructor | AsyncInstructor:
|
|
return _from_openai_compat(
|
|
client=client,
|
|
provider=Provider.PERPLEXITY,
|
|
mode=mode,
|
|
model=model,
|
|
**kwargs,
|
|
)
|
|
|
|
|
|
__all__ = ["from_perplexity"]
|