Skip to content

Commit

Permalink
[FIX] Fixing timeout for prompt execution (#58)
Browse files Browse the repository at this point in the history
* Exception handling for Prompt Service

* Fixing timeout

* Fixing timeout

* Fixing typo
  • Loading branch information
harini-venkataraman authored Jun 11, 2024
1 parent e8979f5 commit 9f2dbd7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/unstract/sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.31.0"
__version__ = "0.31.1"


def get_sdk_version():
Expand Down
2 changes: 1 addition & 1 deletion src/unstract/sdk/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def index_file(
)

@deprecated(
"Deprecated class and method. Use Index and query_texy_from_index() instead"
"Deprecated class and method. Use Index and query_index() instead"
)
def get_text_from_index(
self, embedding_type: str, vector_db: str, doc_id: str
Expand Down
11 changes: 2 additions & 9 deletions src/unstract/sdk/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any, Optional

import requests
from requests import ConnectionError, RequestException, Response, Timeout
from requests import ConnectionError, RequestException, Response

from unstract.sdk.constants import LogLevel, PromptStudioKeys, ToolEnv
from unstract.sdk.helper import SdkHelper
Expand Down Expand Up @@ -68,21 +68,14 @@ def _post_call(self, url_path: str, payload: dict[str, Any]) -> dict[str, Any]:
headers: dict[str, str] = {"Authorization": f"Bearer {self.bearer_token}"}
response: Response = Response()
try:
response = requests.post(url, json=payload, headers=headers, timeout=600)
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
result["status"] = "OK"
result["structure_output"] = response.text
except ConnectionError as connect_err:
msg = "Unable to connect to prompt service. Please contact admin."
self._stringify_and_stream_err(connect_err, msg)
result["error"] = msg
except Timeout as time_out:
msg = (
"Request to run prompt has timed out. "
"Probable causes might be connectivity issues in LLMs."
)
self._stringify_and_stream_err(time_out, msg)
result["error"] = msg
except RequestException as e:
# Extract error information from the response if available
error_message = str(e)
Expand Down

0 comments on commit 9f2dbd7

Please sign in to comment.