Skip to content

Commit

Permalink
Merge pull request #149 from evelynmitchell/master
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez authored Nov 17, 2023
2 parents 4ea32c3 + 29a2673 commit ca8f1ad
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ Book a [1-on-1 Session with Kye](https://calendly.com/swarm-corp/30min), the Cre
## Usage
We have a small gallery of examples to run here, [for more check out the docs to build your own agent and or swarms!](https://docs.apac.ai)

### Basic Example

<a target="_blank" href="https://colab.research.google.com/github/kyegomez/swarms/blob/master/swarms_example.ipynb">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a> Run example in Colab, using your OpenAI API key.

### `Flow` Example
- Reliable Structure that provides LLMS autonomy
- Extremely Customizeable with stopping conditions, interactivity, dynamical temperature, loop intervals, and so much more
Expand Down
111 changes: 111 additions & 0 deletions swarms_example.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"private_outputs": true,
"provenance": [],
"gpuType": "T4"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "cs5RHepmhkEh"
},
"outputs": [],
"source": [
"!pip3 install swarms"
]
},
{
"cell_type": "markdown",
"source": [
"Copied from the repo, example.py\n",
"Enter your OpenAI API key here."
],
"metadata": {
"id": "-d9k3egzgp2_"
}
},
{
"cell_type": "code",
"source": [
"from swarms.models import OpenAIChat\n",
"from swarms.structs import Flow\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",
"flow = Flow(\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 = flow.load_state(\"flow_state.json\")\n",
"# temp = flow.dynamic_temperature()\n",
"# filter = flow.add_response_filter(\"Trump\")\n",
"out = flow.run(\n",
" \"Generate a 10,000 word blog on mental clarity and the benefits of meditation.\"\n",
")\n",
"# out = flow.validate_response(out)\n",
"# out = flow.analyze_feedback(out)\n",
"# out = flow.print_history_and_memory()\n",
"# # out = flow.save_state(\"flow_state.json\")\n",
"# print(out)"
],
"metadata": {
"id": "K1Sbq4UkgVjk"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Look at the log, which may be empty."
],
"metadata": {
"id": "6VtgQ0F4BNc-"
}
},
{
"cell_type": "code",
"source": [
"!cat errors.txt"
],
"metadata": {
"id": "RqL5LL3xBLWR"
},
"execution_count": null,
"outputs": []
}
]
}

0 comments on commit ca8f1ad

Please sign in to comment.