Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix docs - env variables, default model and init code #349

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/guides/javascript/interpreter-agent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ description: "This is a simple guide to demonstrate how to use CODEINTERPRETER t
<CodeGroup>
```javascript Model
const llm = new ChatOpenAI({
model: "gpt-4",
model: "gpt-4o",
apiKey: process.env.OPEN_AI_API_KEY
});
```
Expand Down Expand Up @@ -131,7 +131,7 @@ Here's the complete JavaScript code for the Code Execution Agent:
});

const llm = new ChatOpenAI({
model: "gpt-4",
model: "gpt-4o",
apiKey: process.env.OPEN_AI_API_KEY
});

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/python/rag_agent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ This project involves setting up and running a system of agents to add content t
tools = toolset.get_tools(apps=[App.RAGTOOL])

# Initialize the ChatOpenAI model with GPT-4 and API key from environment variables
llm = ChatOpenAI(model="gpt-4o", openai_api_key=os.environ["OPENAI_API_KEY"])
llm = ChatOpenAI(model="gpt-4o")

# User-provided description of the data to be added and the query
additional_content_list = [
Expand Down
1 change: 0 additions & 1 deletion docs/guides/python/research-assistant.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ Below is the complete code snippet combining all the steps:

# Initialize the language model with OpenAI API key and model name
llm = ChatOpenAI(
openai_api_key=os.environ["OPENAI_API_KEY"],
model_name="gpt-4o"
)

Expand Down
2 changes: 1 addition & 1 deletion docs/javascript/langchain.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function executeAgent (entityName){
// Create an agent
const prompt = await pull("hwchase17/openai-functions-agent");
const llm = new ChatOpenAI({
model: "gpt-4",
model: "gpt-4o",
apiKey: process.env.OPEN_AI_API_KEY
});

Expand Down
2 changes: 1 addition & 1 deletion js/examples/langchain/demo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ app.get('/webhook', async (req, res) => {
const body = "TITLE: HELLO WORLD, DESCRIPTION: HELLO WORLD for the repo - utkarsh-dixit/speedy"

const llm = new ChatOpenAI({
model: "gpt-4",
model: "gpt-4o",
});

const toolset = new LangchainToolSet({
Expand Down
2 changes: 1 addition & 1 deletion js/examples/langchain/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ app.get('/webhook', async (req, res) => {
const body = "TITLE: HELLO WORLD, DESCRIPTION: HELLO WORLD for the repo - utkarsh-dixit/speedy"

const llm = new ChatOpenAI({
model: "gpt-4",
model: "gpt-4o",
});

const toolset = new LangchainToolSet({
Expand Down
2 changes: 1 addition & 1 deletion js/examples/langchain/sample.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function executeAgent(entityName) {

const prompt = await pull("hwchase17/openai-functions-agent");
const llm = new ChatOpenAI({
model: "gpt-4",
model: "gpt-4o",
apiKey: process.env.OPEN_AI_API_KEY
});

Expand Down
8 changes: 2 additions & 6 deletions python/examples/image_search/image_search_crewai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
# Load environment variables from a .env file
dotenv.load_dotenv()

api_key = os.getenv("OPENAI_API_KEY", "")
if api_key == "":
api_key = input("Enter OpenAI API Key:")
os.environ["OPENAI_API_KEY"] = api_key

# Initialize a ChatOpenAI instance with GPT-4o model
llm = ChatOpenAI(model="gpt-4o")

Expand Down Expand Up @@ -70,8 +65,9 @@
# human_input=True # Indicates that human input is allowed/required
)

crew = Crew(agents=[image_search_agent], tasks=[image_search_task])
# Execute the task and retrieve the result
result = image_search_task.execute()
result = crew.kickoff()

# Print the result
print(result)
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main():

def search_images(images_path, search_prompt, top_no_of_images):
# Initialize LLM
llm = ChatOpenAI(model="gpt-4")
llm = ChatOpenAI(model="gpt-4o")

# Get prompt from LangChain hub
prompt = hub.pull("hwchase17/openai-functions-agent")
Expand Down
5 changes: 0 additions & 5 deletions python/examples/image_search/image_search_langchain/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
# Load environment variables from a .env file (if applicable)
dotenv.load_dotenv() # Uncomment if you are using a .env file

api_key = os.getenv("OPENAI_API_KEY", "")
if api_key == "":
api_key = input("Enter OpenAI API Key:")
os.environ["OPENAI_API_KEY"] = api_key


# Initialize a ChatOpenAI instance with GPT-4o model
llm = ChatOpenAI(model="gpt-4o")
Expand Down
7 changes: 1 addition & 6 deletions python/examples/image_search/image_search_langgraph/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,14 @@

dotenv.load_dotenv()

api_key = os.getenv("OPENAI_API_KEY", "")
if api_key == "":
api_key = input("Enter OpenAI API Key:")
os.environ["OPENAI_API_KEY"] = api_key


composio_toolset = ComposioToolSet()
# Retrieve tools from Composio, specifically the EMBEDTOOL app
tools = composio_toolset.get_tools(apps=[App.EMBEDTOOL])
tool_executor = ToolExecutor(tools)
functions = [convert_to_openai_function(t) for t in tools]

model = ChatOpenAI(model="gpt-4", temperature=0, streaming=True)
model = ChatOpenAI(model="gpt-4o", temperature=0, streaming=True)
model = model.bind_functions(functions)


Expand Down
6 changes: 0 additions & 6 deletions python/examples/image_search/image_search_llamaindex/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
# Load environment variables from a .env file
dotenv.load_dotenv()

api_key = os.getenv("OPENAI_API_KEY", "")
if api_key == "":
api_key = input("Enter OpenAI API Key:")
os.environ["OPENAI_API_KEY"] = api_key


# Initialize a ComposioToolSet with the API key from environment variables
toolset = ComposioToolSet()

Expand Down
2 changes: 1 addition & 1 deletion python/examples/local_tools/autogen_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
system_message="Reply TERMINATE when the task is done or when user's content is empty",
llm_config={
"config_list": [
{"model": "gpt-4", "api_key": os.environ["OPENAI_API_KEY"]},
{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]},
]
},
)
Expand Down
8 changes: 5 additions & 3 deletions python/examples/miscellaneous/gmail_send_attachment_crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

import dotenv
from composio_crewai import Action, ComposioToolSet
from crewai import Agent, Task
from crewai import Agent, Task, Crew
from langchain_openai import ChatOpenAI


# Load environment variables from .env
dotenv.load_dotenv()

# Initialize tools.
openai_client = ChatOpenAI(api_key=os.environ["OPENAI_API_KEY"])
openai_client = ChatOpenAI(model="gpt-4o")
composio_toolset = ComposioToolSet()

# Get All the tools
Expand Down Expand Up @@ -42,4 +42,6 @@
)

# Execute task
task.execute()
my_crew = Crew(agents=[crewai_agent], tasks=[task])
result = my_crew.kickoff()
print(result)
7 changes: 2 additions & 5 deletions python/examples/pr_agent/pr_agent_crewai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,10 @@
"""
)

api_key = os.getenv("OPENAI_API_KEY", "")
if api_key == "":
api_key = input("Enter OPENAI API KEY:")
os.environ["OPENAI_API_KEY"] = api_key


# Initialize the language model
llm = ChatOpenAI(model="gpt-4")
llm = ChatOpenAI(model="gpt-4o")

# Create CrewAI agent
code_reviewer = Agent(
Expand Down
2 changes: 1 addition & 1 deletion python/examples/pr_agent/pr_agent_langchain/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@


# Initialize the language model
llm = ChatOpenAI(model="gpt-4")
llm = ChatOpenAI(model="gpt-4o")


prompt = hub.pull("hwchase17/openai-functions-agent")
Expand Down
5 changes: 1 addition & 4 deletions python/examples/pr_agent/pr_agent_llama_index/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
Action.SLACKBOT_CHAT_POST_MESSAGE,
]
)
api_key = os.getenv("OPENAI_API_KEY", "")
if api_key == "":
api_key = input("Enter OpenAI key:")
os.environ["OPENAI_API_KEY"] = api_key

# Initialize an OpenAI instance with the GPT-4o model
llm = OpenAI(model="gpt-4o")

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/autogen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ from composio_autogen import ComposioToolset, App, Action
import os

# Configuration for the language model
llm_config = {"config_list": [{"model": "gpt-4", "api_key": os.environ["OPENAI_API_KEY"]}]}
llm_config = {"config_list": [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}]}

# Initialize the AssistantAgent
chatbot = AssistantAgent(
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/autogen/autogen_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
system_message="Reply TERMINATE when the task is done or when user's content is empty",
llm_config={
"config_list": [
{"model": "gpt-4", "api_key": os.environ["OPENAI_API_KEY"]},
{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]},
]
},
)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/julep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ agent = client.agents.create(
name=name,
about=about,
default_settings=default_settings,
model="gpt-4",
model="gpt-4o",
tools=composio_tools,
)
```
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/julep/julep_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
name=name,
about=about,
default_settings=default_settings,
model="gpt-4",
model="gpt-4o",
tools=composio_tools,
),
)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/langchain/langchain_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
prompt = hub.pull("hwchase17/openai-functions-agent")

# Initialize tools.
openai_client = ChatOpenAI(api_key=os.environ["OPENAI_API_KEY"])
openai_client = ChatOpenAI(model="gpt-4o")


def main():
Expand Down
3 changes: 1 addition & 2 deletions python/swe/examples/crewai_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
from langchain_openai import ChatOpenAI
from prompts import BACKSTORY, DESCRIPTION, EXPECTED_OUTPUT, GOAL, ROLE


# Load environment variables from .env
dotenv.load_dotenv()

# Initialize tool.
openai_client = ChatOpenAI(
api_key=os.environ["OPENAI_API_KEY"], model="gpt-4-turbo" # type: ignore
model="gpt-4o" # type: ignore
)
composio_toolset = ComposioToolSet(workspace_config=WorkspaceType.Docker())

Expand Down
Loading