MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / verify_native_fc_e2e

Function verify_native_fc_e2e

tests/verify_native_fc_e2e.py:6–113  ·  view source on GitHub ↗

E2E verification script for Native Function Calling. This script connects to a running local proxy and sends a request with tool definitions to verify that the proxy correctly handles the request and returns tool calls.

()

Source from the content-addressed store, hash-verified

4
5
6def verify_native_fc_e2e():
7 """
8 E2E verification script for Native Function Calling.
9
10 This script connects to a running local proxy and sends a request with tool definitions
11 to verify that the proxy correctly handles the request and returns tool calls.
12 """
13 base_url = "http://127.0.0.1:2048"
14 chat_url = f"{base_url}/v1/chat/completions"
15 health_url = f"{base_url}/health"
16
17 print("--- Native Function Calling E2E Verification ---")
18
19 # 1. Check if proxy is running
20 print(f"Checking proxy health at {health_url}...")
21 try:
22 health_resp = requests.get(health_url, timeout=5)
23 if health_resp.status_code == 200:
24 print(f"Proxy is UP. Status: {health_resp.json().get('status', 'Unknown')}")
25 else:
26 print(f"Proxy health check failed with status {health_resp.status_code}.")
27 print(
28 "Please ensure the proxy server is running before executing this script."
29 )
30 return
31 except requests.exceptions.ConnectionError:
32 print(f"CRITICAL: Could not connect to proxy at {base_url}.")
33 print("Please start the proxy server (e.g., python server.py) first.")
34 return
35 except Exception as e:
36 print(f"Warning: Health check failed with error: {e}")
37 # Continue anyway, health check might not be implemented exactly as expected
38
39 # 2. Prepare request with tools
40 headers = {"Content-Type": "application/json", "Authorization": "Bearer any-key"}
41
42 payload = {
43 "model": "gemini-3-flash-preview",
44 "messages": [
45 {"role": "user", "content": "What is the weather in Tokyo and Paris?"}
46 ],
47 "tools": [
48 {
49 "type": "function",
50 "function": {
51 "name": "get_weather",
52 "description": "Get the current weather in a given location",
53 "parameters": {
54 "type": "object",
55 "properties": {
56 "location": {
57 "type": "string",
58 "description": "The city and state, e.g. San Francisco, CA",
59 },
60 "unit": {
61 "type": "string",
62 "enum": ["celsius", "fahrenheit"],
63 },

Callers 1

Calls 1

getMethod · 0.45

Tested by

no test coverage detected