mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-27 14:25:20 +02:00
按照要求修改
This commit is contained in:
parent
e2af76fb08
commit
f3c7da32a0
41 changed files with 342 additions and 944 deletions
|
|
@ -8,7 +8,7 @@
|
|||
import pytest
|
||||
|
||||
from metagpt.actions.write_code import WriteCode
|
||||
import metagpt.llm as LLM
|
||||
from metagpt.llm import LLM
|
||||
from metagpt.logs import logger
|
||||
from tests.metagpt.actions.mock import TASKS_2, WRITE_CODE_PROMPT_SAMPLE
|
||||
|
||||
|
|
@ -29,6 +29,6 @@ async def test_write_code():
|
|||
@pytest.mark.asyncio
|
||||
async def test_write_code_directly():
|
||||
prompt = WRITE_CODE_PROMPT_SAMPLE + '\n' + TASKS_2[0]
|
||||
llm=LLM.DEFAULT_LLM
|
||||
llm = LLM()
|
||||
rsp = await llm.aask(prompt)
|
||||
logger.info(rsp)
|
||||
|
|
|
|||
|
|
@ -21,35 +21,35 @@ def test_ltm_search():
|
|||
|
||||
idea = 'Write a cli snake game'
|
||||
message = Message(role='BOSS', content=idea, cause_by=BossRequirement)
|
||||
news = ltm.remember([message])
|
||||
news = ltm.find_news([message])
|
||||
assert len(news) == 1
|
||||
ltm.add(message)
|
||||
|
||||
sim_idea = 'Write a game of cli snake'
|
||||
sim_message = Message(role='BOSS', content=sim_idea, cause_by=BossRequirement)
|
||||
news = ltm.remember([sim_message])
|
||||
news = ltm.find_news([sim_message])
|
||||
assert len(news) == 0
|
||||
ltm.add(sim_message)
|
||||
|
||||
new_idea = 'Write a 2048 web game'
|
||||
new_message = Message(role='BOSS', content=new_idea, cause_by=BossRequirement)
|
||||
news = ltm.remember([new_message])
|
||||
news = ltm.find_news([new_message])
|
||||
assert len(news) == 1
|
||||
ltm.add(new_message)
|
||||
|
||||
# restore from local index
|
||||
ltm_new = LongTermMemory()
|
||||
ltm_new.recover_memory(role_id, rc)
|
||||
news = ltm_new.remember([message])
|
||||
news = ltm_new.find_news([message])
|
||||
assert len(news) == 0
|
||||
|
||||
ltm_new.recover_memory(role_id, rc)
|
||||
news = ltm_new.remember([sim_message])
|
||||
news = ltm_new.find_news([sim_message])
|
||||
assert len(news) == 0
|
||||
|
||||
new_idea = 'Write a Battle City'
|
||||
new_message = Message(role='BOSS', content=new_idea, cause_by=BossRequirement)
|
||||
news = ltm_new.remember([new_message])
|
||||
news = ltm_new.find_news([new_message])
|
||||
assert len(news) == 1
|
||||
|
||||
ltm_new.clear()
|
||||
|
|
|
|||
4
tests/metagpt/provider/test_xinghuo_api.py
Normal file
4
tests/metagpt/provider/test_xinghuo_api.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
from metagpt.provider.spark_api import SparkAPI
|
||||
def test_message():
|
||||
llm=SparkAPI()
|
||||
llm.ask('只回答"收到了"这三个字。')
|
||||
|
|
@ -16,7 +16,7 @@ DETAIL_REQUIREMENT = """需求:开发一个基于LLM(大语言模型)与
|
|||
3. 私有知识库支持pdf、word、txt等各种文件格式上传,上传后可以在服务端解析为文本,存储ES
|
||||
|
||||
资源:
|
||||
1. 大语言模型已经有前置的抽象、部署,可以通过 `import metagpt.llm as LLM`,再使用`LLM().ask(prompt)`直接调用
|
||||
1. 大语言模型已经有前置的抽象、部署,可以通过 `from metagpt.llm import LLM`,再使用`LLM().ask(prompt)`直接调用
|
||||
2. Elastic已有[部署](http://192.168.50.82:9200/),代码可以直接使用这个部署"""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import pytest
|
||||
|
||||
import metagpt.llm as LLM
|
||||
from metagpt.llm import LLM
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
|
|
|
|||
42
tests/metagpt/tools/test_moderation.py
Normal file
42
tests/metagpt/tools/test_moderation.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Time : 2023/9/26 14:46
|
||||
@Author : zhanglei
|
||||
@File : test_translate.py
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from metagpt.tools.moderation import Moderation
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("content",),
|
||||
[
|
||||
[
|
||||
["I will kill you", "The weather is really nice today", "I want to hit you"],
|
||||
]
|
||||
],
|
||||
)
|
||||
def test_moderation(content):
|
||||
moderation = Moderation()
|
||||
results = moderation.moderation(content=content)
|
||||
assert isinstance(results, list)
|
||||
assert len(results) == len(content)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
("content",),
|
||||
[
|
||||
[
|
||||
["I will kill you", "The weather is really nice today", "I want to hit you"],
|
||||
]
|
||||
],
|
||||
)
|
||||
async def test_amoderation(content):
|
||||
moderation = Moderation()
|
||||
results = await moderation.amoderation(content=content)
|
||||
assert isinstance(results, list)
|
||||
assert len(results) == len(content)
|
||||
Loading…
Add table
Add a link
Reference in a new issue