Skip to content

Commit 246bbe5

Browse files
authored
Merge pull request #455 from ishitachauhan12/main
Add auth-key support and validation to vLLM
2 parents a72b842 + 7471691 commit 246bbe5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/vanna/vllm/vllm.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ def __init__(self, config=None):
1717
else:
1818
self.model = config["model"]
1919

20+
if "auth-key" in config:
21+
self.auth_key = config["auth-key"]
22+
else:
23+
self.auth_key = None
24+
2025
def system_message(self, message: str) -> any:
2126
return {"role": "system", "content": message}
2227

@@ -67,7 +72,17 @@ def submit_prompt(self, prompt, **kwargs) -> str:
6772
"messages": prompt,
6873
}
6974

70-
response = requests.post(url, json=data)
75+
if self.auth_key is not None:
76+
headers = {
77+
'Content-Type': 'application/json',
78+
'Authorization': f'Bearer {self.auth_key}'
79+
}
80+
81+
response = requests.post(url, headers=headers,json=data)
82+
83+
84+
else:
85+
response = requests.post(url, json=data)
7186

7287
response_dict = response.json()
7388

0 commit comments

Comments
 (0)