Skip to content

Commit

Permalink
Add temperature support to vLLM
Browse files Browse the repository at this point in the history
Added temperature support for hosted LLM using vLLM

Changes made:
* Introduced default temperature of 0.7 in __init__ method
* Updated JSON payload in submit_prompt method to include temperature


This change allows users to control the randomness of the model's output. 
If not specified, it defaults to 0.7, providing a balance between 
creativity and coherence in the generated text.
  • Loading branch information
AmitSinghShorthillsAI authored Sep 16, 2024
1 parent 40cab58 commit a0c8007
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/vanna/vllm/vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ def __init__(self, config=None):
else:
self.auth_key = None

if "temperature" in config:
self.temperature = config["temperature"]
else:
# default temperature - can be overrided using config
self.temperature = 0.7

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

Expand Down Expand Up @@ -68,6 +74,7 @@ def submit_prompt(self, prompt, **kwargs) -> str:
url = f"{self.host}/v1/chat/completions"
data = {
"model": self.model,
"temperature": self.temperature,
"stream": False,
"messages": prompt,
}
Expand Down

0 comments on commit a0c8007

Please sign in to comment.