-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspecvalidator.py
More file actions
29 lines (24 loc) · 847 Bytes
/
specvalidator.py
File metadata and controls
29 lines (24 loc) · 847 Bytes
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
import json
from pathlib import Path
import requests
from openapi_core import OpenAPI, Config
from openapi_core.contrib.requests import RequestsOpenAPIRequest
config = Config(
spec_validator_cls=None,
)
openapi = OpenAPI.from_file_path('./2024-02-15-preview.json', config=config)
# Load the JSON body from a local file
json_body_path = Path("./input.json")
json_body = json.loads(json_body_path.read_text())
# Create a POST request
url = "https://localhost:3000/openai/deployments/mydeployment/chat/completions"
headers = {"Accept": "application/json", "Content-Type": "application/json"}
request = requests.Request(
method="POST",
url=url,
headers=headers,
json=json_body
)
openapi_request = RequestsOpenAPIRequest(request.prepare())
result = openapi.unmarshal_request(openapi_request) #breaks on this line
print(result)