initial code for working with openrouter

This commit is contained in:
JV 2023-08-15 03:35:55 +12:00 committed by Joshua Vial
parent 8c580dd332
commit 041f3a4a38
11 changed files with 99 additions and 26 deletions

View file

@ -636,7 +636,7 @@ class Coder:
if len(chunk.choices) == 0:
continue
if chunk.choices[0].finish_reason == "length":
if hasattr(chunk.choices[0], "finish_reason") and chunk.choices[0].finish_reason == "length":
raise ExhaustedContextWindow()
try:
@ -901,5 +901,6 @@ class Coder:
def check_model_availability(main_model):
available_models = openai.Model.list()
print(available_models)
model_ids = [model.id for model in available_models["data"]]
return main_model.name in model_ids