| try: | try: | ||||
| response = post(url, headers=headers, data=dumps(data)) | response = post(url, headers=headers, data=dumps(data)) | ||||
| except Exception as e: | except Exception as e: | ||||
| raise InvokeConnectionError(e) | |||||
| raise InvokeConnectionError(str(e)) | |||||
| if response.status_code != 200: | if response.status_code != 200: | ||||
| try: | try: |
| try: | try: | ||||
| response = post(url, headers=headers, data=dumps(data)) | response = post(url, headers=headers, data=dumps(data)) | ||||
| except Exception as e: | except Exception as e: | ||||
| raise InvokeConnectionError(e) | |||||
| raise InvokeConnectionError(str(e)) | |||||
| if response.status_code != 200: | if response.status_code != 200: | ||||
| try: | try: |
| try: | try: | ||||
| response = post(join(url, 'embeddings'), headers=headers, data=dumps(data), timeout=10) | response = post(join(url, 'embeddings'), headers=headers, data=dumps(data), timeout=10) | ||||
| except Exception as e: | except Exception as e: | ||||
| raise InvokeConnectionError(e) | |||||
| raise InvokeConnectionError(str(e)) | |||||
| if response.status_code != 200: | if response.status_code != 200: | ||||
| try: | try: |
| try: | try: | ||||
| response = post(url, headers=headers, data=dumps(data)) | response = post(url, headers=headers, data=dumps(data)) | ||||
| except Exception as e: | except Exception as e: | ||||
| raise InvokeConnectionError(e) | |||||
| raise InvokeConnectionError(str(e)) | |||||
| if response.status_code != 200: | if response.status_code != 200: | ||||
| raise InvokeServerUnavailableError(response.text) | raise InvokeServerUnavailableError(response.text) |
| # cloud not connect to the server | # cloud not connect to the server | ||||
| raise InvokeAuthorizationError(f"Invalid server URL: {e}") | raise InvokeAuthorizationError(f"Invalid server URL: {e}") | ||||
| except Exception as e: | except Exception as e: | ||||
| raise InvokeConnectionError(e) | |||||
| raise InvokeConnectionError(str(e)) | |||||
| if response.status_code != 200: | if response.status_code != 200: | ||||
| if response.status_code == 400: | if response.status_code == 400: |