Skip to content

Commit

Permalink
reprebot/refac: #20 remove fake-llm
Browse files Browse the repository at this point in the history
- remove `FakeLLM` implementation because `langchain-contrib`
  doesn't support latest version of `langchain`
- remove `langchain-contrib` dependency
- update `langchain` to latest version: `0.1.11` #23
- remove `TestFakeLLM` unit test
- restore `TestLLMClient` unit test
- add versions to `direct-requirements.txt`
  • Loading branch information
este6an13 committed Mar 12, 2024
1 parent d1fde92 commit b729372
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Reprebot relies on the following dependencies:

- `chromadb`
- `langchain`
- `langchain-contrib`
- `langchain-openai`
- `pytest`

Expand Down
9 changes: 4 additions & 5 deletions direct-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
chromadb
langchain
langchain-contrib
langchain-openai
pytest
chromadb==0.4.24
langchain==0.1.11
langchain-openai==0.0.8
pytest==8.1.1
18 changes: 8 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
aiohttp==3.9.3
aiosignal==1.3.1
annotated-types==0.6.0
anyio==4.3.0
asgiref==3.7.2
attrs==23.2.0
Expand All @@ -14,16 +15,14 @@ chromadb==0.4.24
click==8.1.7
colorama==0.4.6
coloredlogs==15.0.1
dataclasses-json==0.5.14
dataclasses-json==0.6.4
Deprecated==1.2.14
distro==1.9.0
executing==2.0.1
fastapi==0.110.0
filelock==3.13.1
flatbuffers==24.3.7
frozenlist==1.4.1
fsspec==2024.2.0
fvalues==0.0.3
google-auth==2.28.2
googleapis-common-protos==1.63.0
greenlet==3.0.3
Expand All @@ -41,10 +40,11 @@ iniconfig==2.0.0
jsonpatch==1.33
jsonpointer==2.4
kubernetes==29.0.0
langchain==0.0.119
langchain-contrib==0.0.4
langchain==0.1.11
langchain-community==0.0.27
langchain-core==0.1.30
langchain-openai==0.0.8
langchain-text-splitters==0.0.1
langsmith==0.1.23
marshmallow==3.21.1
mmh3==4.1.0
Expand All @@ -69,15 +69,14 @@ opentelemetry-util-http==0.44b0
orjson==3.9.15
overrides==7.7.0
packaging==23.2
pexpect==4.9.0
pluggy==1.4.0
posthog==3.5.0
protobuf==4.25.3
ptyprocess==0.7.0
pulsar-client==3.4.0
pyasn1==0.5.1
pyasn1-modules==0.3.0
pydantic==1.10.14
pydantic==2.6.4
pydantic_core==2.16.3
PyPika==0.48.9
pyproject_hooks==1.0.0
pyreadline3==3.4.1
Expand All @@ -89,10 +88,9 @@ regex==2023.12.25
requests==2.31.0
requests-oauthlib==1.4.0
rsa==4.9
simple-term-menu==1.6.4
six==1.16.0
sniffio==1.3.1
SQLAlchemy==1.4.52
SQLAlchemy==2.0.28
starlette==0.36.3
sympy==1.12
tenacity==8.2.3
Expand Down
4 changes: 0 additions & 4 deletions src/llm_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
from langchain_openai import ChatOpenAI
from langchain_contrib.llms.testing import FakeLLM

class LLMClient:
def __init__(self, model_type: str):
Expand All @@ -17,9 +16,6 @@ def setup_model(self, temperature=0):
model_name="gpt-3.5-turbo-0125",
temperature=temperature
)
# not supported on Windows
elif self.model_type == "fake":
model = FakeLLM()
"""
elif self.model_type == "hugging-face":
llm = HuggingFaceEndpoint(
Expand Down
14 changes: 8 additions & 6 deletions test/unit/src/test_llm_client.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import os
import pytest
from src.llm_client import LLMClient
from langchain_contrib.llms.testing import FakeLLM

class TestFakeLLM:
class TestLLMClient:
@pytest.fixture
def llm_client(self):
return LLMClient(model_type="fake")
return LLMClient(model_type="gpt")

def test_init(self, llm_client):
assert llm_client.model_type == "fake"
assert llm_client.openai_api_key == os.environ.get("OPENAI_API_KEY")
assert llm_client.model_type == "gpt"

def test_setup_model(self, llm_client):
model = llm_client.setup_model()
assert isinstance(model, FakeLLM)
temperature = 0.5
model = llm_client.setup_model(temperature=temperature)
assert model.temperature == temperature

0 comments on commit b729372

Please sign in to comment.