API call to post data
(base_url: str, api_key: str, endpoint: str, data: dict)
| 20 | |
| 21 | |
| 22 | def post(base_url: str, api_key: str, endpoint: str, data: dict) -> dict: |
| 23 | """ |
| 24 | API call to post data |
| 25 | """ |
| 26 | access_token = get_access_token(api_key) |
| 27 | |
| 28 | response = requests.post( |
| 29 | f"{base_url}/prompts", |
| 30 | json={ |
| 31 | "data": |
| 32 | { |
| 33 | "method": "post", |
| 34 | "headers": { |
| 35 | "Content-Type": "application/json", |
| 36 | }, |
| 37 | "route": endpoint, |
| 38 | "data": data, |
| 39 | }, |
| 40 | }, |
| 41 | headers={"Authorization": f"Bearer {access_token}"}, |
| 42 | ) |
| 43 | |
| 44 | response_json = response.json() |
| 45 | if response.status_code != 200: |
| 46 | raise ValueError(f"Failed to post data: {response_json}") |
| 47 | |
| 48 | return response_json["data"] |
| 49 | |
| 50 | |
| 51 | def create_agent( |
no test coverage detected