Skip to content

Commit a6dd153

Browse files
authored
Merge pull request LISARDGGY-Hackathon#32 from Young-TW/main
refactor: merge resp and suffix operations
2 parents ef8c3d8 + 5be3d5a commit a6dd153

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/vllm.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,9 @@ def completions(prompt: str, host: str):
3939
url = host.rstrip("/") + "/" + path.lstrip("/")
4040

4141
try:
42-
resp = requests.post(url, json=body, headers={"Content-Type": "application/json"}, timeout=120.0, verify=False)
42+
resp = requests.post(url, json=body, headers={"Content-Type": "application/json"}, timeout=10.0, verify=False)
43+
suffix = re.findall(r'\[\[(.*?)\]\]', resp.json()['choices'][0]['message']["content"])[-1]
44+
return suffix
4345
except requests.RequestException as e:
4446
print("Request error:", e)
4547
return
46-
47-
# print(f"Upstream URL: {url} Status: {resp.status_code}")
48-
try:
49-
suffix = re.findall(r'\[\[(.*?)\]\]', resp.json()['choices'][0]['message']["content"])[-1]
50-
return suffix
51-
# return resp.json()['choices'][0]['message']["content"]
52-
except Exception as e:
53-
print(f"Something went wrong! {e}")

0 commit comments

Comments
 (0)