-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
71 lines (63 loc) · 1.98 KB
/
test.py
File metadata and controls
71 lines (63 loc) · 1.98 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Example usage of Edgee Gateway SDK"""
import os
import sys
# Add parent directory to path for local testing
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from edgee import Edgee
edgee = Edgee(os.environ.get("EDGEE_API_KEY", "test-key"))
# Test 1: Simple string input
print("Test 1: Simple string input")
response1 = edgee.send(
model="mistral/mistral-small-latest",
input="What is the capital of France?",
)
print(f"Content: {response1.text}")
print(f"Usage: {response1.usage}")
print()
# Test 2: Full input object with messages
print("Test 2: Full input object with messages")
response2 = edgee.send(
model="mistral/mistral-small-latest",
input={
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Say hello!"},
],
},
)
print(f"Content: {response2.text}")
print()
# Test 3: With tools
print("Test 3: With tools")
response3 = edgee.send(
model="gpt-5.2",
input={
"messages": [{"role": "user", "content": "What is the weather in Paris?"}],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"},
},
"required": ["location"],
},
},
},
],
"tool_choice": "auto",
},
)
print(f"Content: {response3.text}")
print(f"Tool calls: {response3.tool_calls}")
print()
# Test 4: Streaming
print("Test 4: Streaming")
for chunk in edgee.stream(model="mistral/mistral-small-latest", input="What is Python?"):
if chunk.text:
print(chunk.text, end="", flush=True)
print("\n")