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.
swarms/playground/demos/langchain_example/langchain_example.py

27 lines
531 B

import os
from dotenv import load_dotenv
from swarms import Agent
from langchain.llms import OpenAIChat
# Loading environment variables from .env file
load_dotenv()
# Initialize the model
llm = OpenAIChat(
openai_api_key=os.getenv("OPENAI_API_KEY"),
max_tokens=1000,
)
# Initialize the agent
agent = Agent(
llm=llm,
max_loops="auto",
autosave=True,
dashboard=False,
streaming_on=True,
verbose=True,
)
# Run the workflow on a task
agent.run("Generate a 10,000 word blog on health and wellness.")