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

@ -50,6 +50,12 @@ def send_with_retries(model, messages, functions, stream):
if hasattr(openai, "api_engine"):
kwargs["engine"] = openai.api_engine
if "openrouter.ai" in openai.api_base:
kwargs["headers"] = {
"HTTP-Referer": "http://aider.chat",
"X-Title": "Aider"
}
key = json.dumps(kwargs, sort_keys=True).encode()
# Generate SHA1 hash of kwargs and append it to chat_completion_call_hashes