CoolFace
Apppublic

Ck773/llama-cpp

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
crewai.ipynb158 linesDownload Raw Back to root
1{2 "cells": [3  {4   "cell_type": "code",5   "execution_count": 1,6   "metadata": {},7   "outputs": [8    {9     "name": "stderr",10     "output_type": "stream",11     "text": [12      "UsageError: Line magic function `%jupyter` not found.\n"13     ]14    }15   ],16   "source": [17    "%jupyter lab --version"18   ]19  },20  {21   "cell_type": "code",22   "execution_count": null,23   "metadata": {},24   "outputs": [],25   "source": [26    "%pip install crewai\n",27    "# %pip install 'crewai[tools]'"28   ]29  },30  {31   "cell_type": "code",32   "execution_count": 17,33   "metadata": {},34   "outputs": [35    {36     "name": "stdout",37     "output_type": "stream",38     "text": [39      "Python 3.9.5\n"40     ]41    }42   ],43   "source": [44    "!python3 --version"45   ]46  },47  {48   "cell_type": "code",49   "execution_count": null,50   "metadata": {},51   "outputs": [],52   "source": [53    "import os\n",54    "from crewai import Agent\n",55    "# from crewai_tools import SerperDevTool\n",56    "\n",57    "# os.environ[\"OPENAI_API_BASE\"] = \"https://ck773-llama-cpp.hf.space\"\n",58    "# os.environ[\"OPENAI_API_KEY\"] = \"crewai\"\n",59    "# os.environ[\"SERPER_API_KEY\"] = \"1cf134642ac156860045fe6000b18f6d435983ef\" # serper.dev API key"60   ]61  },62  {63   "cell_type": "code",64   "execution_count": null,65   "metadata": {},66   "outputs": [],67   "source": [68    "import os\n",69    "from crewai import Agent, Task, Crew, Process\n",70    "from crewai_tools import SerperDevTool\n",71    "\n",72    "\n",73    "os.environ[\"OPENAI_API_BASE\"] = \"https://ck773-llama-cpp.hf.space\"\n",74    "os.environ[\"OPENAI_API_KEY\"] = \"crewai\"\n",75    "os.environ[\"SERPER_API_KEY\"] = \"1cf134642ac156860045fe6000b18f6d435983ef\" # serper.dev API key\n",76    "\n",77    "# You can choose to use a local model through Ollama for example. See https://docs.crewai.com/how-to/LLM-Connections/ for more information.\n",78    "\n",79    "# os.environ[\"OPENAI_API_BASE\"] = 'http://localhost:11434/v1'\n",80    "# os.environ[\"OPENAI_MODEL_NAME\"] ='openhermes'  # Adjust based on available model\n",81    "# os.environ[\"OPENAI_API_KEY\"] ='sk-111111111111111111111111111111111111111111111111'\n",82    "\n",83    "search_tool = SerperDevTool()\n",84    "\n",85    "# Define your agents with roles and goals\n",86    "researcher = Agent(\n",87    "  role='Senior Research Analyst',\n",88    "  goal='AI Agent for create learning video using RevealJs, Bark, Deepface',\n",89    "  backstory=\"\"\"You work at a leading tech think tank.\n",90    "  Your expertise lies in identifying emerging trends.\n",91    "  You have a knack for dissecting complex data and presenting actionable insights.\"\"\",\n",92    "  verbose=True,\n",93    "  allow_delegation=False,\n",94    "  tools=[search_tool]\n",95    "  # You can pass an optional llm attribute specifying what model you wanna use.\n",96    "  # It can be a local model through Ollama / LM Studio or a remote\n",97    "  # model like OpenAI, Mistral, Antrophic or others (https://docs.crewai.com/how-to/LLM-Connections/)\n",98    "  #\n",99    "  # import os\n",100    "  # os.environ['OPENAI_MODEL_NAME'] = 'gpt-3.5-turbo'\n",101    "  #\n",102    "  # OR\n",103    "  #\n",104    "  # from langchain_openai import ChatOpenAI\n",105    "  # llm=ChatOpenAI(model_name=\"gpt-3.5\", temperature=0.7)\n",106    ")\n",107    "writer = Agent(\n",108    "  role='Tech Content Strategist',\n",109    "  goal='Craft compelling content on tech advancements',\n",110    "  backstory=\"\"\"You are a renowned Content Strategist, known for your insightful and engaging articles.\n",111    "  You transform complex concepts into compelling narratives.\"\"\",\n",112    "  verbose=True,\n",113    "  allow_delegation=True\n",114    ")\n",115    "\n",116    "# Create tasks for your agents\n",117    "task1 = Task(\n",118    "  description=\"\"\"Conduct a comprehensive analysis of the latest advancements in AI in 2024.\n",119    "  Identify key trends, breakthrough technologies, and potential industry impacts.\"\"\",\n",120    "  expected_output=\"Full analysis report in bullet points\",\n",121    "  agent=researcher\n",122    ")\n",123    "\n",124    "task2 = Task(\n",125    "  description=\"\"\"Using the insights provided, develop an engaging blog\n",126    "  post that highlights the most significant AI advancements.\n",127    "  Your post should be informative yet accessible, catering to a tech-savvy audience.\n",128    "  Make it sound cool, avoid complex words so it doesn't sound like AI.\"\"\",\n",129    "  expected_output=\"Full blog post of at least 4 paragraphs\",\n",130    "  agent=writer\n",131    ")\n",132    "\n",133    "# Instantiate your crew with a sequential process\n",134    "crew = Crew(\n",135    "  agents=[researcher, writer],\n",136    "  tasks=[task1, task2],\n",137    "  verbose=2, # You can set it to 1 or 2 to different logging levels\n",138    ")\n",139    "\n",140    "# Get your crew to work!\n",141    "result = crew.kickoff()\n",142    "\n",143    "print(\"######################\")\n",144    "print(result)"145   ]146  }147 ],148 "metadata": {149  "kernelspec": {150   "display_name": "Python 3 (ipykernel)",151   "language": "python",152   "name": "python3"153  }154 },155 "nbformat": 4,156 "nbformat_minor": 2157}158