-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_crewai_llm.py
More file actions
51 lines (43 loc) · 1.02 KB
/
check_crewai_llm.py
File metadata and controls
51 lines (43 loc) · 1.02 KB
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
import os
from dotenv import load_dotenv
from crewai import Agent, Task, Crew, LLM
load_dotenv()
# Check environment variables
print(f"CREWAI_MODEL: {os.getenv('CREWAI_MODEL')}")
print(f"OPENAI_API_BASE: {os.getenv('OPENAI_API_BASE')}")
print(f"OPENAI_API_KEY: {os.getenv('OPENAI_API_KEY')}")
model = os.getenv("CREWAI_MODEL", "openai/qwen2.5:7b")
print(f"Using model: {model}")
try:
llm = LLM(model=model)
except Exception as e:
print(f"Error initializing LLM: {e}")
exit(1)
# Define a simple agent
agent = Agent(
role='Tester',
goal='Verify LLM connection',
backstory='You are a test agent.',
verbose=True,
llm=llm
)
# Define a simple task
task = Task(
description='Say "Hello, World!"',
expected_output='Hello, World!',
agent=agent
)
# Define the crew
crew = Crew(
agents=[agent],
tasks=[task],
verbose=True
)
# Kickoff
try:
result = crew.kickoff()
print("\nSuccess! Result:")
print(result)
except Exception as e:
print("\nError during kickoff:")
print(e)