fixbug: type error

This commit is contained in:
莘权 马 2024-04-07 13:27:10 +08:00
parent ef3563500f
commit ffa0a6223d
3 changed files with 25 additions and 8 deletions

View file

@ -1,7 +1,8 @@
from __future__ import annotations
import asyncio
from enum import Enum
from typing import List, Tuple
from typing import Tuple
from pydantic import BaseModel
@ -89,8 +90,9 @@ You should follow the following Standard Operating Procedure:
class DetectIntent(Action):
async def run(self, user_msgs: List[Message]) -> Tuple[str, str]:
user_requirement = "\n".join([f"> {i.role}: {i.content}" for i in user_msgs])
async def run(self, with_message: Message, **kwargs) -> Tuple[str, str]:
ref_content = with_message.content.replace("\n", "\n> ")
user_requirement = f"> {with_message.role}: {ref_content}"
intentions = "\n".join([f"{si.type_name}: {si.value.description}" for si in SOPItem])
prompt = DETECT_PROMPT.format(user_requirement=user_requirement, intentions=intentions)
@ -104,3 +106,18 @@ class DetectIntent(Action):
)
return req_with_sop, sop_type
async def main():
# Example usage of the DetectIntent action
user_requirements = ["Develop a 2048 game.", "Run data analysis on sklearn wine dataset"]
detect_intent = DetectIntent()
for user_requirement in user_requirements:
req_with_sop, sop_type = await detect_intent.run(Message(role="user", content=user_requirement))
print(req_with_sop)
print(f"Detected SOP Type: {sop_type}")
if __name__ == "__main__":
asyncio.run(main())