fix n=1 issue with langchain

This commit is contained in:
Krrish Dholakia 2023-10-03 11:06:59 -07:00
parent 29ab9b5463
commit e834c063ff
5 changed files with 9 additions and 3 deletions

View file

@ -726,7 +726,7 @@ def test_completion_replicate_vicuna():
def test_completion_together_ai():
model_name = "together_ai/togethercomputer/llama-2-70b-chat"
try:
response = completion(model=model_name, messages=messages, max_tokens=256, logger_fn=logger_fn)
response = completion(model=model_name, messages=messages, max_tokens=256, n=1, logger_fn=logger_fn)
# Add any assertions here to check the response
print(response)
cost = completion_cost(completion_response=response)

View file

@ -980,7 +980,13 @@ def get_optional_params( # use the openai defaults
print_verbose(f"checking params for {model}")
print_verbose(f"params passed in {passed_params}")
print_verbose(f"non-default params passed in {non_default_params}")
unsupported_params = [k for k in non_default_params.keys() if k not in supported_params]
unsupported_params = []
for k in non_default_params.keys():
if k not in supported_params:
if k == "n" and n == 1: # langchain sends n=1 as a default value
pass
else:
unsupported_params.append(k)
if unsupported_params:
raise ValueError("LiteLLM.Exception: Unsupported parameters passed: {}".format(', '.join(unsupported_params)))

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "litellm"
version = "0.1.816"
version = "0.1.817"
description = "Library to easily interface with LLM API providers"
authors = ["BerriAI"]
license = "MIT License"