121 lines
2.9 KiB
Python
Raw Normal View History

Sample Web Application Built with AutoGen (#695) * Adding research assistant code * Adding research assistant code * checking in RA files * Remove used text file * Update README.md to include Saleema's name to the Contributors list. * remove extraneous files * update gitignore * improve structure on global skills * fix linting error * readme update * readme update * fix wrong function bug * readme update * update ui build * cleanup, remove unused modules * readme and docs updates * set default user * ui build update * add screenshot to improve instructions * remove logout behaviour, replace with note to developers to add their own logout logic * Create blog and edit ARA README * Added the stock prices example in the readme for ARA * Include edits from review with Saleema * fix format issues * Cosmetic changes for betting debug messages * edit authors * remove references to request_timeout to support autogen v0.0.2 * update bg color for UI * readme update * update research assistant blog post * omit samples folder from codecov * ui build update + precommit refactor * formattiing updates fromo pre-commit * readme update * remove compiled source files * update gitignore * refactor, file removals * refactor for improved structure - datamodel, chat and db helper * update gitignore * refactor, file removals * refactor for improved structure - datamodel, chat and db helper * refactor skills view * general refactor * gitignore update and general refactor * skills update * general refactor * ui folder structure refactor * improve support for skills loading * add fetch profile default skill * refactor chat to autogenchat * qol refactor * improve metadata display * early support for autogenflow in ui * docs update general refactor * general refactor * readme update * readme update * readme and cli update * pre-commit updates * precommit update * readme update * add steup.py for older python build versions * add manifest.in, update app icon * in-progress changes to agent specification * remove use_cache refs * update datamodel, and fix for default serverurl * request_timeout * readme update, fix autogen values * fix pyautogen version * precommit formatting and other qol items * update folder structure * req update * readme and docs update * docs update * remove duplicate in yaml file * add support for explicit skills addition * readme and documentation updates * general refactor * remove blog post, schedule for future PR * readme update, add info on llmconfig * make use_cache False by default unless set * minor ui updates * upgrade ui to use latest uatogen lib version 0.2.0b5 * Ui refactor, support for adding arbitrary model specifications * formatting/precommit checks * update readme, utils default skill --------- Co-authored-by: Piali Choudhury <pialic@microsoft.com> Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
import uuid
from datetime import datetime
from typing import Any, Callable, Dict, List, Literal, Optional, Union
from pydantic.dataclasses import dataclass
from dataclasses import field
@dataclass
class Message(object):
user_id: str
role: str
content: str
root_msg_id: Optional[str] = None
msg_id: Optional[str] = None
timestamp: Optional[datetime] = None
personalize: Optional[bool] = False
ra: Optional[str] = None
code: Optional[str] = None
metadata: Optional[Any] = None
def __post_init__(self):
if self.msg_id is None:
self.msg_id = str(uuid.uuid4())
if self.timestamp is None:
self.timestamp = datetime.now()
def dict(self):
return {
"user_id": self.user_id,
"role": self.role,
"content": self.content,
"root_msg_id": self.root_msg_id,
"msg_id": self.msg_id,
"timestamp": self.timestamp,
"personalize": self.personalize,
"ra": self.ra,
"code": self.code,
"metadata": self.metadata,
}
# web api data models
# autogenflow data models
@dataclass
class ModelConfig:
"""Data model for Model Config item in LLMConfig for Autogen"""
model: str
api_key: Optional[str] = None
base_url: Optional[str] = None
api_type: Optional[str] = None
api_version: Optional[str] = None
@dataclass
class LLMConfig:
"""Data model for LLM Config for Autogen"""
config_list: List[Any] = field(default_factory=List)
temperature: float = 0
cache_seed: Optional[Union[int, None]] = None
timeout: Optional[int] = None
@dataclass
class AgentConfig:
"""Data model for Agent Config for Autogen"""
name: str
llm_config: Optional[LLMConfig] = None
human_input_mode: str = "NEVER"
max_consecutive_auto_reply: int = 10
system_message: Optional[str] = None
is_termination_msg: Optional[Union[bool, str, Callable]] = None
code_execution_config: Optional[Union[bool, str, Dict[str, Any]]] = None
@dataclass
class AgentFlowSpec:
"""Data model to help flow load agents from config"""
type: Literal["assistant", "userproxy", "groupchat"]
config: AgentConfig = field(default_factory=AgentConfig)
@dataclass
class FlowConfig:
"""Data model for Flow Config for Autogen"""
name: str
sender: AgentFlowSpec
receiver: Union[AgentFlowSpec, List[AgentFlowSpec]]
type: Literal["default", "groupchat"] = "default"
@dataclass
class ChatWebRequestModel(object):
"""Data model for Chat Web Request for Web End"""
message: Message
flow_config: FlowConfig
@dataclass
class DeleteMessageWebRequestModel(object):
user_id: str
msg_id: str
@dataclass
class ClearDBWebRequestModel(object):
user_id: str
@dataclass
class CreateSkillWebRequestModel(object):
user_id: str
skills: Union[str, List[str]]