Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f49e442
feat: update OpenAI model parameters handling for reasoning models
ogabrielluiz Jun 9, 2025
914fc91
feat: extend input_value type in LCModelComponent to support AsyncIte…
ogabrielluiz Jun 9, 2025
3d7e76c
refactor: remove assert_streaming_sequence method and related checks …
ogabrielluiz Jun 9, 2025
9dd9205
feat: add consume_iterator method to Message class for handling itera…
ogabrielluiz Jun 9, 2025
0623d6b
test: add unit tests for OpenAIModelComponent functionality and integ…
ogabrielluiz Jun 9, 2025
996a3bf
feat: update OpenAIModelComponent to include temperature and seed par…
ogabrielluiz Jun 9, 2025
600ece6
feat: rename consume_iterator method to consume_iterator_in_text and …
ogabrielluiz Jun 9, 2025
b029115
feat: add is_connected_to_chat_output method to Component class for i…
ogabrielluiz Jun 11, 2025
d576d96
feat: refactor LCModelComponent methods to support asynchronous messa…
ogabrielluiz Jun 11, 2025
abc3891
refactor: remove consume_iterator_in_text method from Message class a…
ogabrielluiz Jun 11, 2025
aa24bee
fix: update import paths for input components in multiple starter pro…
ogabrielluiz Jun 11, 2025
452dcb2
fix: enhance error message formatting in ErrorMessage class to handle…
ogabrielluiz Jun 11, 2025
1398034
refactor: remove validate_stream calls from generate_flow_events and …
ogabrielluiz Jun 11, 2025
987f912
fix: handle asyncio.CancelledError in aadd_messagetables to ensure pr…
ogabrielluiz Jun 11, 2025
929fbc2
refactor: streamline message handling in LCModelComponent by replacin…
ogabrielluiz Jun 11, 2025
3714612
refactor: enhance message handling in LCModelComponent by introducing…
ogabrielluiz Jun 12, 2025
cb9ba56
feat: add _build_source method to Component class for enhanced source…
ogabrielluiz Jun 12, 2025
037e553
feat: enhance LCModelComponent by adding _handle_stream method for im…
ogabrielluiz Jun 12, 2025
614fac4
feat: update MemoryComponent to enhance message retrieval and storage…
ogabrielluiz Jun 12, 2025
a1d8421
Merge branch 'main' into improve-streaming
ogabrielluiz Jun 12, 2025
d031c91
test: refactor LanguageModelComponent tests to use ComponentTestBaseW…
ogabrielluiz Jun 12, 2025
1547e9f
test: add fixtures for API keys and implement live API tests for Open…
ogabrielluiz Jun 12, 2025
fdb1ad5
Merge branch 'main' into improve-streaming
ogabrielluiz Jun 23, 2025
0aa9519
fix: reorder JSON properties for consistency in starter projects
ogabrielluiz Jun 23, 2025
663e47e
refactor: simplify input_value type in LCModelComponent
ogabrielluiz Jun 25, 2025
1fd3656
fix: clarify comment for handling source in Component class
ogabrielluiz Jun 25, 2025
2755422
Merge branch 'main' into improve-streaming
ogabrielluiz Jun 25, 2025
c1b8d5f
refactor: remove unnecessary mocking in OpenAI model integration tests
ogabrielluiz Jun 25, 2025
dafb3c0
Merge branch 'main' into improve-streaming
ogabrielluiz Jun 25, 2025
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
Prev Previous commit
Next Next commit
test: add fixtures for API keys and implement live API tests for Open…
…AI, Anthropic, and Google models
  • Loading branch information
ogabrielluiz committed Jun 12, 2025
commit 1547e9f97023b9a2c26617dde9d4ade652264fdc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import pytest
from langchain_anthropic import ChatAnthropic
from langchain_google_genai import ChatGoogleGenerativeAI
Expand Down Expand Up @@ -33,6 +35,30 @@ def file_names_mapping(self):
# No version-specific files for this component
return []

@pytest.fixture
def openai_api_key(self):
"""Fixture to get OpenAI API key from environment variable."""
api_key = os.environ.get("OPENAI_API_KEY")
if not api_key:
pytest.skip("OPENAI_API_KEY environment variable not set")
return api_key

@pytest.fixture
def anthropic_api_key(self):
"""Fixture to get Anthropic API key from environment variable."""
api_key = os.environ.get("ANTHROPIC_API_KEY")
if not api_key:
pytest.skip("ANTHROPIC_API_KEY environment variable not set")
return api_key

@pytest.fixture
def google_api_key(self):
"""Fixture to get Google API key from environment variable."""
api_key = os.environ.get("GOOGLE_API_KEY")
if not api_key:
pytest.skip("GOOGLE_API_KEY environment variable not set")
return api_key

async def test_update_build_config_openai(self, component_class, default_kwargs):
component = component_class(**default_kwargs)
build_config = {
Expand Down Expand Up @@ -149,3 +175,45 @@ async def test_build_model_unknown_provider(self, component_class, default_kwarg

with pytest.raises(ValueError, match="Unknown provider: Unknown"):
component.build_model()

async def test_openai_live_api(self, component_class, default_kwargs, openai_api_key):
"""Test that the component can create a model with a real API key."""
component = component_class(**default_kwargs)
component.provider = "OpenAI"
component.model_name = "gpt-3.5-turbo"
component.api_key = openai_api_key
component.temperature = 0.1
component.stream = False

model = component.build_model()
assert isinstance(model, ChatOpenAI)
# We could attempt a simple call here, but that would increase test time
# and might fail due to network issues, so we'll just verify the instance

async def test_anthropic_live_api(self, component_class, default_kwargs, anthropic_api_key):
"""Test that the component can create a model with a real API key."""
component = component_class(**default_kwargs)
component.provider = "Anthropic"
component.model_name = ANTHROPIC_MODELS[0]
component.api_key = anthropic_api_key
component.temperature = 0.1
component.stream = False

model = component.build_model()
assert isinstance(model, ChatAnthropic)
# We could attempt a simple call here, but that would increase test time
# and might fail due to network issues, so we'll just verify the instance

async def test_google_live_api(self, component_class, default_kwargs, google_api_key):
"""Test that the component can create a model with a real API key."""
component = component_class(**default_kwargs)
component.provider = "Google"
component.model_name = GOOGLE_GENERATIVE_AI_MODELS[0]
component.api_key = google_api_key
component.temperature = 0.1
component.stream = False

model = component.build_model()
assert isinstance(model, ChatGoogleGenerativeAI)
# We could attempt a simple call here, but that would increase test time
# and might fail due to network issues, so we'll just verify the instance
Loading