159 fix examples to use env keys

pull/153/head
evelynmitchell 1 year ago
parent 0d00697595
commit f587e58d30

@ -38,6 +38,14 @@ 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)
All of the examples assume you have set your API keys in the environment:
```bash
export OPENAI_API_KEY='yourapikey'
export ANTHROPIC_API_KEY='yourotherapikey'
```
### Example in Colab:
<a target="_blank" href="https://colab.research.google.com/github/kyegomez/swarms/blob/master/swarms_example.ipynb">

@ -1,5 +1,9 @@
from swarms.models import OpenAIChat
from swarms.structs import Flow
import os
openai_api_key = os.environ.get("OPENAI_API_KEY")
anthropic_api_key = os.environ.get("ANTHROPIC_API_KEY")
# Initialize the language model, this model can be swapped out with Anthropic, ETC, Huggingface Models like Mistral, ETC
llm = OpenAIChat(

@ -1,16 +1,15 @@
from swarms.models import OpenAIChat, BioGPT, Anthropic
from swarms.structs import Flow
from swarms.structs.sequential_workflow import SequentialWorkflow
import os
# Example usage
api_key = (
"" # Your actual API key here
)
openai_api_key = os.environ.get("OPENAI_API_KEY")
anthropic_api_key = os.environ.get("ANTHROPIC_API_KEY")
# Initialize the language flow
llm = OpenAIChat(
openai_api_key=api_key,
openai_api_key=openai_api_key,
temperature=0.5,
max_tokens=3000,
)
@ -18,7 +17,7 @@ llm = OpenAIChat(
biochat = BioGPT()
# Use Anthropic
anthropic = Anthropic()
anthropic = Anthropic(anthropic_api_key=anthropic_api_key)
# Initialize the agent with the language flow
agent1 = Flow(llm=llm, max_loops=1, dashboard=False)

Loading…
Cancel
Save