Skip to content

Commit

Permalink
fix: workaround for refactor on new versions of langchain (#924)
Browse files Browse the repository at this point in the history
* fix: workaround for refactor on new versions of langchain

* build(deps): updated dependency locks
  • Loading branch information
ErikBjare authored Dec 21, 2023
1 parent a74c5eb commit 242f37d
Show file tree
Hide file tree
Showing 2 changed files with 308 additions and 280 deletions.
13 changes: 12 additions & 1 deletion gpt_engineer/core/token_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@

import tiktoken

from langchain.callbacks.openai_info import get_openai_token_cost_for_model
from langchain.schema import AIMessage, HumanMessage, SystemMessage

# workaround for function moved in:
# https://github.com/langchain-ai/langchain/blob/535db72607c4ae308566ede4af65295967bb33a8/libs/community/langchain_community/callbacks/openai_info.py
try:
from langchain.callbacks.openai_info import (
get_openai_token_cost_for_model, # fmt: skip
)
except ImportError:
from langchain_community.callbacks.openai_info import (
get_openai_token_cost_for_model, # fmt: skip
)


Message = Union[AIMessage, HumanMessage, SystemMessage]

logger = logging.getLogger(__name__)
Expand Down
Loading

0 comments on commit 242f37d

Please sign in to comment.