Skip to content

Commit

Permalink
upgrade langchain
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaim Turkel authored and Chaim Turkel committed Jan 31, 2024
1 parent 2a95513 commit 9e7386b
Show file tree
Hide file tree
Showing 9 changed files with 1,473 additions and 1,351 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,5 @@ dmypy.json

# Pyre type checker
.pyre/

.DS_Store
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ schema = Object(
)

chain = create_extraction_chain(llm, schema, encoder_or_encoder_class='json')
chain.run("play songs by paul simon and led zeppelin and the doors")['data']
chain.invoke("play songs by paul simon and led zeppelin and the doors")['data']
```

```python
Expand Down Expand Up @@ -150,7 +150,7 @@ schema, validator = from_pydantic(MusicRequest)
chain = create_extraction_chain(
llm, schema, encoder_or_encoder_class="json", validator=validator
)
chain.run("stop the music now")["validated_data"]
chain.invoke("stop the music now")["validated_data"]
```

```python
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ schema = Object(
)

chain = create_extraction_chain(llm, schema, encoder_or_encoder_class='json')
chain.run("play songs by paul simon and led zeppelin and the doors")['data']
chain.invoke("play songs by paul simon and led zeppelin and the doors")['data']
```

```python
Expand Down Expand Up @@ -116,7 +116,7 @@ schema, validator = from_pydantic(MusicRequest)
chain = create_extraction_chain(
llm, schema, encoder_or_encoder_class="json", validator=validator
)
chain.run("stop the music now")["validated_data"]
chain.invoke("stop the music now")["validated_data"]
```

```python
Expand Down
2 changes: 1 addition & 1 deletion kor/extraction/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import asyncio
from typing import Any, Callable, List, Optional, Sequence, Type, Union, cast

from langchain import PromptTemplate
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain.docstore.document import Document

Expand Down
3 changes: 1 addition & 2 deletions kor/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from typing import Any, List, Optional, Tuple

from langchain import BasePromptTemplate
from langchain.prompts import PromptTemplate
from langchain.prompts import BasePromptTemplate, PromptTemplate
from langchain.schema import (
AIMessage,
BaseMessage,
Expand Down
2,799 changes: 1,460 additions & 1,339 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository = "https://www.github.com/eyurtsev/kor"

[tool.poetry.dependencies]
python = "^3.8.1"
langchain = ">=0.0.205"
langchain = ">=0.1.4"
pandas = "^1.5.3"
markdownify = {version = "^0.11.6", optional = false}
pydantic = "<3"
Expand Down
6 changes: 3 additions & 3 deletions tests/extraction/test_extraction_with_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import langchain
import pytest
from langchain import PromptTemplate
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain

from kor.encoders import CSVEncoder, JSONEncoder
Expand Down Expand Up @@ -42,7 +42,7 @@ def test_create_extraction_chain(options: Mapping[str, Any]) -> None:
chain = create_extraction_chain(chat_model, schema, **options)
assert isinstance(chain, LLMChain)
# Try to run through predict and parse
chain.run("some string")
chain.invoke("some string")


@pytest.mark.parametrize(
Expand All @@ -62,7 +62,7 @@ def test_create_extraction_chain_with_csv_encoder(options: Mapping[str, Any]) ->
chain = create_extraction_chain(chat_model, **options)
assert isinstance(chain, LLMChain)
# Try to run through predict and parse
chain.run("some string")
chain.invoke("some string")


MANY_TEXT_SCHEMA = Text(
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/extraction_with_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Person(BaseModel):
)

chain = create_extraction_chain(llm, schema)
result = chain.run("My name is Bobby. My brother's name Joe.") # type: ignore
result = chain.invoke("My name is Bobby. My brother's name Joe.") # type: ignore
data = result["data"] # type: ignore

assert "person" in data # type: ignore
Expand Down

0 comments on commit 9e7386b

Please sign in to comment.