Skip to content

Commit c8d41ac

Browse files
authored
Merge pull request Pythagora-io#771 from Pythagora-io/anthropic-openrouter-fixes
Don't ignore openrouter settings if using anthropic with openrouter
2 parents 97e8648 + 38024ed commit c8d41ac

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pilot/.env.example

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ AZURE_ENDPOINT=
1010

1111
OPENROUTER_API_KEY=
1212

13+
# Set this to use Anthropic API directly
14+
# If using via OpenRouter, OPENROUTER_API_KEY should be set instead
1315
ANTHROPIC_API_KEY=
1416

1517
# You only need to set this if not using Anthropic API directly (eg. via proxy or AWS Bedrock)
16-
ANTHROPIC_ENDPOINT=
18+
# ANTHROPIC_ENDPOINT=
1719

1820
# In case of Azure/OpenRouter endpoint, change this to your deployed model name
1921
MODEL_NAME=gpt-4-turbo-preview

pilot/utils/llm_connection.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def create_gpt_chat_completion(messages: List[dict], req_type, project,
140140
model_provider = 'openai'
141141

142142
try:
143-
if model_provider == 'anthropic':
143+
if model_provider == 'anthropic' and os.getenv('ENDPOINT') != 'OPENROUTER':
144144
if not os.getenv('ANTHROPIC_API_KEY'):
145145
os.environ['ANTHROPIC_API_KEY'] = os.getenv('OPENAI_API_KEY')
146146
response = stream_anthropic(messages, function_call_message, gpt_data, model_name)
@@ -609,7 +609,7 @@ def stream_anthropic(messages, function_call_message, gpt_data, model_name = "cl
609609
raise RuntimeError("The 'anthropic' package is required to use the Anthropic Claude LLM.") from err
610610

611611
client = anthropic.Anthropic(
612-
base_url=os.getenv('ANTHROPIC_ENDPOINT'),
612+
base_url=os.getenv('ANTHROPIC_ENDPOINT') or None,
613613
)
614614

615615
claude_system = "You are a software development AI assistant."

0 commit comments

Comments
 (0)