Skip to content

Commit

Permalink
Merge pull request #5 from Neural-Space/code-fix
Browse files Browse the repository at this point in the history
cleaned code
  • Loading branch information
vik-rant authored Jan 16, 2024
2 parents 2e91358 + b43d8e1 commit f504cba
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions neuralspace/voice_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ def ama(self, job_id: str, prompts: List[str]) -> Dict[str, Any]:
"""
url = f'{K.FULL_AMA_URL.rstrip("/")}'
hdrs = self._create_headers()
hdrs['Content-Type'] = 'application/json'
data = json.dumps({

data = {
"jobId": job_id,
"prompts": prompts
})
}

sess = self._get_session()
r = sess.post(url, headers=hdrs, data=data)
r = sess.post(url, headers=hdrs, json=data)
resp = utils.get_json_resp(r)
return resp

Expand Down Expand Up @@ -411,14 +411,13 @@ def create_custom_dict(self, name: str, words: List[str]) -> Dict[str, Any]:
result: dict
Contains the id of the newly created custom dictionary
'''
payload = json.dumps({
"name": name,
"words": words
})
sess = self._get_session()
headers = self._create_headers()
headers['Content-Type'] = 'application/json'
r = sess.post(K.FULL_VOCAB_ADAPT_URL, headers=headers, data=payload)
data = {
"name": name,
"words": words
}
r = sess.post(K.FULL_VOCAB_ADAPT_URL, headers=headers, json=data)
resp = utils.get_json_resp(r)
return resp

Expand Down Expand Up @@ -478,13 +477,12 @@ def update_custom_dict(self, dict_id: str, op: str, words: List[str]) -> Dict[st
result: dict
contains the message of the operation performed on the custom dictionary.
'''
payload = json.dumps({
"op": op,
"words": words
})
sess = self._get_session()
headers = self._create_headers()
headers['Content-Type'] = 'application/json'
r = sess.patch(f'{K.FULL_VOCAB_ADAPT_URL}/{dict_id}', headers=headers, data=payload)
data = {
"op": op,
"words": words
}
r = sess.patch(f'{K.FULL_VOCAB_ADAPT_URL}/{dict_id}', headers=headers, json=data)
resp = utils.get_json_resp(r)
return resp
return resp

0 comments on commit f504cba

Please sign in to comment.