Skip to content

Commit 8fada9a

Browse files
author
Julien Salinas
committed
DDo not parse the returned JSON if asynchronous request still in progress.
1 parent 485a37e commit 8fada9a

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ If you are making asynchronous requests, you will always receive a quick respons
133133
client.async_result("https://api.nlpcloud.io/v1/get-async-result/21718218-42e8-4be9-a67f-b7e18e03b436")
134134
```
135135

136-
The above command returns a JSON object.
136+
The above command returns a JSON object when the response is ready. It returns `None` otherwise.
137137

138138
### Automatic Speech Recognition (Speech to Text) Endpoint
139139

nlpcloud/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ def async_result(self, url):
7676
except HTTPError as err:
7777
raise HTTPError(str(err) + ": " + str(r.text))
7878

79-
return r.json()
79+
try:
80+
return r.json()
81+
except requests.exceptions.JSONDecodeError:
82+
return None
8083

8184
def chatbot(self, text, context=None, history=None):
8285
payload = {

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='nlpcloud',
5-
version='1.1.44',
5+
version='1.1.45',
66
description='Python client for the NLP Cloud API',
77
long_description="NLP Cloud serves high performance pre-trained or custom models for NER, sentiment-analysis, classification, summarization, paraphrasing, grammar and spelling correction, keywords and keyphrases extraction, chatbot, product description and ad generation, intent classification, text generation, image generation, code generation, question answering, automatic speech recognition, machine translation, language detection, semantic search, semantic similarity, speech synthesis, tokenization, POS tagging, embeddings, and dependency parsing. It is ready for production, served through a REST API.\n\nThis is the Python client for the API.\n\nMore details here: https://nlpcloud.io\n\nDocumentation: https://docs.nlpcloud.io\n\nGithub: https://github.com/nlpcloud/nlpcloud-python",
88
packages=['nlpcloud'],

0 commit comments

Comments
 (0)