{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from miniautogen.chat.chat import Chat\n",
    "from miniautogen.agent.agent import Agent\n",
    "from miniautogen.chat.chatadmin import ChatAdmin\n",
    "from miniautogen.pipeline.pipeline import Pipeline\n",
    "from miniautogen.pipeline.components import (\n",
    "    UserResponseComponent, \n",
    "    NextAgentSelectorComponent, \n",
    "    AgentReplyComponent, \n",
    "    TerminateChatComponent,\n",
    "    OpenAIThreadComponent\n",
    ")\n",
    "\n",
    "\n",
    "# Instanciação do componente\n",
    "openai_thread_component = OpenAIThreadComponent()\n",
    "\n",
    "# Configuração do assistant_id\n",
    "openai_thread_component.set_assistant_id('asst_2YhkVro5x2C0IoUoylfkjrgN')\n",
    "\n",
    "# Criação do pipeline com o componente configurado\n",
    "pipeline_thread = Pipeline([openai_thread_component])\n",
    "\n",
    "# Configuração dos demais Pipelines\n",
    "pipeline_user = Pipeline([UserResponseComponent()])\n",
    "pipeline_admin = Pipeline([NextAgentSelectorComponent(), AgentReplyComponent(), TerminateChatComponent()])\n",
    "\n",
    "# Setup do ambiente de teste\n",
    "chat = Chat()\n",
    "json_data = {\n",
    "    'agent_id': 'Bruno',\n",
    "    'name': 'Bruno',\n",
    "    'role': 'user'\n",
    "}\n",
    "\n",
    "# Criação de Agentes\n",
    "agent1 = Agent.from_json(json_data)\n",
    "agent1.pipeline = pipeline_user  # Atribuindo o pipeline ao agente\n",
    "\n",
    "agent2 = Agent(\"assistant\", \"OpenAI Assistant\", \"OpenAI Agent\")\n",
    "agent2.pipeline = pipeline_thread  # Atribuindo o pipeline_thread ao terceiro agente\n",
    "\n",
    "# Adicionando os agentes ao chat\n",
    "chat.add_agent(agent1)\n",
    "chat.add_agent(agent2)\n",
    "\n",
    "# Criação e configuração do ChatAdmin\n",
    "chat_admin = ChatAdmin(\"admin\", \"Admin\", \"admin_role\", pipeline_admin, chat, \"manage_chat\", 10)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Executando o ChatAdmin\n",
    "chat_admin.run()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "chat.get_messages('json')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
