Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade langchain #257

Merged
merged 4 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
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
Loading