참고소스 수정본
This commit is contained in:
40
참고/instructor-main/tests/llm/test_genai/conftest.py
Normal file
40
참고/instructor-main/tests/llm/test_genai/conftest.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# conftest.py
|
||||
import os
|
||||
import pytest
|
||||
|
||||
import instructor
|
||||
|
||||
if not os.getenv("GOOGLE_API_KEY"):
|
||||
pytest.skip(
|
||||
"GOOGLE_API_KEY environment variable not set",
|
||||
allow_module_level=True,
|
||||
)
|
||||
|
||||
if not os.getenv("GOOGLE_GENAI_MODEL"):
|
||||
pytest.skip(
|
||||
"GOOGLE_GENAI_MODEL environment variable not set",
|
||||
allow_module_level=True,
|
||||
)
|
||||
|
||||
try:
|
||||
from google.genai import Client
|
||||
except ImportError: # pragma: no cover - optional dependency
|
||||
pytest.skip("google-genai package is not installed", allow_module_level=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def client():
|
||||
yield Client()
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def aclient():
|
||||
yield Client()
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def genai_client():
|
||||
# Use the recommended model for sync client, let the test set the mode
|
||||
return instructor.from_provider(
|
||||
os.getenv("GOOGLE_GENAI_MODEL", "google/gemini-pro"),
|
||||
)
|
||||
Reference in New Issue
Block a user