You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.4 KiB
109 lines
2.4 KiB
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"id": "cs5RHepmhkEh"
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"!pip3 install swarms"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"id": "-d9k3egzgp2_"
|
|
},
|
|
"source": [
|
|
"Copied from the repo, example.py\n",
|
|
"Enter your OpenAI API key here."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"id": "K1Sbq4UkgVjk"
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from swarms.models import OpenAIChat\n",
|
|
"from swarms.structs import Agent\n",
|
|
"\n",
|
|
"api_key = \"\"\n",
|
|
"\n",
|
|
"# Initialize the language model, this model can be swapped out with Anthropic, ETC, Huggingface Models like Mistral, ETC\n",
|
|
"llm = OpenAIChat(\n",
|
|
" # model_name=\"gpt-4\"\n",
|
|
" openai_api_key=api_key,\n",
|
|
" temperature=0.5,\n",
|
|
" # max_tokens=100,\n",
|
|
")\n",
|
|
"\n",
|
|
"\n",
|
|
"## Initialize the workflow\n",
|
|
"agent = Agent(\n",
|
|
" llm=llm,\n",
|
|
" max_loops=5,\n",
|
|
" dashboard=True,\n",
|
|
" # tools = [search_api, slack, ]\n",
|
|
" # stopping_condition=None, # You can define a stopping condition as needed.\n",
|
|
" # loop_interval=1,\n",
|
|
" # retry_attempts=3,\n",
|
|
" # retry_interval=1,\n",
|
|
" # interactive=False, # Set to 'True' for interactive mode.\n",
|
|
" # dynamic_temperature=False, # Set to 'True' for dynamic temperature handling.\n",
|
|
")\n",
|
|
"\n",
|
|
"# out = agent.load_state(\"flow_state.json\")\n",
|
|
"# temp = agent.dynamic_temperature()\n",
|
|
"# filter = agent.add_response_filter(\"Trump\")\n",
|
|
"out = agent.run(\n",
|
|
" \"Generate a 10,000 word blog on mental clarity and the benefits\"\n",
|
|
" \" of meditation.\"\n",
|
|
")\n",
|
|
"print(out)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"id": "6VtgQ0F4BNc-"
|
|
},
|
|
"source": [
|
|
"Look at the log, which may be empty."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"id": "RqL5LL3xBLWR"
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"!cat errors.txt"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"accelerator": "GPU",
|
|
"colab": {
|
|
"gpuType": "T4",
|
|
"private_outputs": true,
|
|
"provenance": []
|
|
},
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"name": "python"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 0
|
|
}
|