Skip to content

Commit

Permalink
use sed to change get_messages() to messages
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Nov 27, 2024
1 parent 56e6b7b commit ea55fd1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions libs/elasticsearch/langchain_elasticsearch/_sync/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ def clear(self, **kwargs: Any) -> None:
class ElasticsearchEmbeddingsCache(ByteStore):
"""An Elasticsearch store for caching embeddings.
For synchronous applications, use the ``ElasticsearchEmbeddingsCache`` class.
For asyhchronous applications, use the ``AsyncElasticsearchEmbeddingsCache`` class.
For synchronous applications, use the `ElasticsearchEmbeddingsCache` class.
For asyhchronous applications, use the `AsyncElasticsearchEmbeddingsCache` class.
"""

def __init__(
Expand Down
8 changes: 2 additions & 6 deletions libs/elasticsearch/scripts/run_unasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,19 @@ def main(check=False):
subprocess.check_call(["ruff", "format", "--target-version=py38", output_dir])
subprocess.check_call(["isort", output_dir])
for file in glob("*.py", root_dir=dir[0]):
# remove asyncio from sync files
subprocess.check_call(
["sed", "-i.bak", "/^import asyncio$/d", f"{output_dir}{file}"]
)
subprocess.check_call(
[
"sed",
"-i.bak",
"s/asyncio\\.run(main())/main()/",
"s/pytest.mark.asyncio/pytest.mark.sync/",
f"{output_dir}{file}",
]
)
subprocess.check_call(
[
"sed",
"-i.bak",
"s/pytest.mark.asyncio/pytest.mark.sync/",
"s/get_messages()/messages/",
f"{output_dir}{file}",
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def test_memory_with_message_store(
)

# get the message history from the memory store and turn it into a json
messages = await memory.chat_memory.aget_messages() # type: ignore[attr-defined]
messages = await memory.chat_memory.aget_messages()
messages_json = json.dumps([message_to_dict(msg) for msg in messages])

assert "This is me, the AI" in messages_json
Expand All @@ -69,4 +69,4 @@ async def test_memory_with_message_store(
# remove the record from Elasticsearch, so the next test run won't pick it up
await memory.chat_memory.aclear()

assert await memory.chat_memory.aget_messages() == [] # type: ignore[attr-defined]
assert await memory.chat_memory.aget_messages() == []
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_memory_with_message_store(
)

# get the message history from the memory store and turn it into a json
messages = memory.chat_memory.get_messages() # type: ignore[attr-defined]
messages = memory.chat_memory.messages
messages_json = json.dumps([message_to_dict(msg) for msg in messages])

assert "This is me, the AI" in messages_json
Expand All @@ -69,4 +69,4 @@ def test_memory_with_message_store(
# remove the record from Elasticsearch, so the next test run won't pick it up
memory.chat_memory.clear()

assert memory.chat_memory.get_messages() == [] # type: ignore[attr-defined]
assert memory.chat_memory.messages == []

0 comments on commit ea55fd1

Please sign in to comment.