Skip to content

Commit

Permalink
Merge pull request #455 from ishitachauhan12/main
Browse files Browse the repository at this point in the history
Add auth-key support and validation to vLLM
  • Loading branch information
zainhoda authored Jun 1, 2024
2 parents a72b842 + 7471691 commit 246bbe5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/vanna/vllm/vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def __init__(self, config=None):
else:
self.model = config["model"]

if "auth-key" in config:
self.auth_key = config["auth-key"]
else:
self.auth_key = None

def system_message(self, message: str) -> any:
return {"role": "system", "content": message}

Expand Down Expand Up @@ -67,7 +72,17 @@ def submit_prompt(self, prompt, **kwargs) -> str:
"messages": prompt,
}

response = requests.post(url, json=data)
if self.auth_key is not None:
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {self.auth_key}'
}

response = requests.post(url, headers=headers,json=data)


else:
response = requests.post(url, json=data)

response_dict = response.json()

Expand Down

0 comments on commit 246bbe5

Please sign in to comment.