Skip to content

Commit

Permalink
DDo not parse the returned JSON if asynchronous request still in prog…
Browse files Browse the repository at this point in the history
…ress.
  • Loading branch information
juliensalinas committed Nov 10, 2023
1 parent 485a37e commit 8fada9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ If you are making asynchronous requests, you will always receive a quick respons
client.async_result("https://api.nlpcloud.io/v1/get-async-result/21718218-42e8-4be9-a67f-b7e18e03b436")
```

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

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

Expand Down
5 changes: 4 additions & 1 deletion nlpcloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def async_result(self, url):
except HTTPError as err:
raise HTTPError(str(err) + ": " + str(r.text))

return r.json()
try:
return r.json()
except requests.exceptions.JSONDecodeError:
return None

def chatbot(self, text, context=None, history=None):
payload = {
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='nlpcloud',
version='1.1.44',
version='1.1.45',
description='Python client for the NLP Cloud API',
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",
packages=['nlpcloud'],
Expand Down

0 comments on commit 8fada9a

Please sign in to comment.