-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathcheck_time_online.py
53 lines (35 loc) · 1.13 KB
/
check_time_online.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import sys
from langchain_anthropic import ChatAnthropic
from langchain_openai import ChatOpenAI
from langchain_google_genai import ChatGoogleGenerativeAI
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import argparse
import asyncio
from mlx_use import Agent
from pydantic import SecretStr
from mlx_use.controller.service import Controller
def set_llm(llm_provider:str = None):
if not llm_provider:
raise ValueError("No llm provider was set")
if llm_provider == "OAI":
api_key = os.getenv('OPENAI_API_KEY')
return ChatOpenAI(model='gpt-4o', api_key=SecretStr(api_key))
if llm_provider == "google":
api_key = os.getenv('GEMINI_API_KEY')
return ChatGoogleGenerativeAI(model='gemini-2.0-flash-exp', api_key=SecretStr(api_key))
llm = set_llm('google')
llm = set_llm('OAI')
controller = Controller()
task = 'Can you check online what hour is Shabbat in israel this week? call done when you finish.'
agent = Agent(
task=task,
llm=llm,
controller=controller,
use_vision=False,
max_actions_per_step=5,
max_failures=5
)
async def main():
await agent.run(max_steps=25)
asyncio.run(main())