Skip to content

Commit

Permalink
Fix/fix langchain retrieval chain (#64)
Browse files Browse the repository at this point in the history
* feat: Support openai 1.14

* chore: Fix issue

* chore: Fix issue

* chore: Update version

* fix/fix-langchain-retrieval-chain

* chore: Add warning for langchain version

* chore: Update version

* chore: Update version
  • Loading branch information
valeriosofi authored Mar 20, 2024
1 parent 58954a1 commit d98db51
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nebuly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from .init import init

__all__ = ["init", "new_interaction"]
__version__ = "0.3.26"
__version__ = "0.3.27"
4 changes: 0 additions & 4 deletions nebuly/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,3 @@ class NotInInteractionContext(InteractionContextError):

class InteractionMustBeLocalVariable(InteractionContextError):
"""Exception raised when the interaction manager creation misses the 'as'"""


class ModelNotSupportedError(Exception):
"""Exception raised when the model is not supported."""
11 changes: 11 additions & 0 deletions nebuly/providers/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import Any, Dict, Sequence, Tuple, cast
from uuid import UUID

import langchain
from langchain.callbacks.base import BaseCallbackHandler
from langchain.chains.base import Chain
from langchain.load import load
Expand Down Expand Up @@ -323,13 +324,23 @@ def __init__( # pylint: disable=too-many-arguments
feature_flags: list[str] | None = None,
nebuly_tags: dict[str, str] | None = None,
) -> None:
self._check_version()
self.api_key = api_key
self.nebuly_user = user_id
self.nebuly_user_group = user_group_profile
self.nebuly_feature_flags = feature_flags
self.nebuly_tags = nebuly_tags
self._events_storage = EventsStorage()

@staticmethod
def _check_version() -> None:
if langchain.__version__ < "0.1.0":
logger.warning(
"LangChain version 0.1.0 or higher is required to use the "
"LangChainTrackingHandler with Nebuly SDK. "
"Please upgrade your LangChain version.",
)

def _send_interaction(self, run_id: uuid.UUID) -> None:
if (
len(self._events_storage.events) < 1
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nebuly"
version = "0.3.26"
version = "0.3.27"
description = "The SDK for instrumenting applications for tracking AI costs."
authors = ["Nebuly"]
readme = "README.md"
Expand Down

0 comments on commit d98db51

Please sign in to comment.