77import sys
88from dotenv import load_dotenv
99
10- load_dotenv ()
11-
12- # Check environment
13- epfl_key = os .getenv ("EPFL_API_KEY" )
14- if not epfl_key :
15- print ("❌ EPFL_API_KEY not found in environment" )
16- print (" Set it in .env or export EPFL_API_KEY=your_key" )
17- if __name__ == "__main__" :
18- sys .exit (1 )
19-
20- print ("✅ EPFL_API_KEY found" )
21- print ()
22-
2310# Test with a simple image
2411from pydantic_ai import Agent
2512from pydantic_ai .models .openai import OpenAIChatModel
@@ -35,24 +22,44 @@ class SimpleResponse(BaseModel):
3522 has_image : bool
3623
3724
38- # Create EPFL provider and model
39- print ("🔄 Creating EPFL model client..." )
40- provider = OpenAIProvider (
41- base_url = "https://inference.rcp.epfl.ch/v1" ,
42- api_key = epfl_key ,
43- )
25+ # When imported (e.g. by pytest), avoid running script-like behavior.
26+ # Provide placeholders so attribute access does not fail.
27+ if __name__ != "__main__" :
28+ epfl_key = None
29+ provider = None
30+ model = None
31+ agent = None
32+ else :
33+ load_dotenv ()
34+
35+ # Check environment
36+ epfl_key = os .getenv ("EPFL_API_KEY" )
37+ if not epfl_key :
38+ print ("❌ EPFL_API_KEY not found in environment" )
39+ print (" Set it in .env or export EPFL_API_KEY=your_key" )
40+ sys .exit (1 )
4441
45- model = OpenAIChatModel (
46- model_name = "openai/gpt-oss-120b" ,
47- provider = provider ,
48- )
42+ print ("✅ EPFL_API_KEY found" )
43+ print ()
4944
50- agent = Agent (
51- model = model ,
52- system_prompt = "You are a helpful assistant. If you receive an image, describe what you see. If no image, say so." ,
53- )
45+ # Create EPFL provider and model
46+ print ("🔄 Creating EPFL model client..." )
47+ provider = OpenAIProvider (
48+ base_url = "https://inference.rcp.epfl.ch/v1" ,
49+ api_key = epfl_key ,
50+ )
51+
52+ model = OpenAIChatModel (
53+ model_name = "openai/gpt-oss-120b" ,
54+ provider = provider ,
55+ )
56+
57+ agent = Agent (
58+ model = model ,
59+ system_prompt = "You are a helpful assistant. If you receive an image, describe what you see. If no image, say so." ,
60+ )
5461
55- print ("✅ EPFL agent created" )
62+ print ("✅ EPFL agent created" )
5663print ()
5764
5865# Test 1: Text-only
0 commit comments