feat: Action Node + exclude parameter

refactor: awrite
This commit is contained in:
莘权 马 2023-12-27 22:46:39 +08:00
parent 0adabfe53f
commit 8bf7d3186a
7 changed files with 58 additions and 53 deletions

View file

@ -12,7 +12,6 @@ import asyncio
from pydantic import BaseModel
from metagpt.learn.text_to_embedding import text_to_embedding
from metagpt.tools.openai_text_to_embedding import ResultEmbedding
async def mock_text_to_embedding():
@ -23,8 +22,7 @@ async def mock_text_to_embedding():
for i in inputs:
seed = Input(**i)
data = await text_to_embedding(seed.input)
v = ResultEmbedding(**data)
v = await text_to_embedding(seed.input)
assert len(v.data) > 0

View file

@ -9,6 +9,7 @@
import importlib
import os
import platform
import uuid
from pathlib import Path
from typing import Any, Set
@ -25,6 +26,8 @@ from metagpt.utils.common import (
OutputParser,
any_to_str,
any_to_str_set,
aread,
awrite,
check_cmd_exists,
concat_namespace,
import_class_inst,
@ -170,6 +173,14 @@ class TestGetProjectRoot:
async def test_read_file_block(self):
assert await read_file_block(filename=__file__, lineno=6, end_lineno=6) == "@File : test_common.py\n"
@pytest.mark.asyncio
async def test_read_write(self):
pathname = Path(__file__).parent / uuid.uuid4().hex / "test.tmp"
await awrite(pathname, "ABC")
data = await aread(pathname)
assert data == "ABC"
pathname.unlink(missing_ok=True)
if __name__ == "__main__":
pytest.main([__file__, "-s"])