Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

Allow to configure openapi base url (#118)

bvandorfabb9552c429f
diff --git a/README.md b/README.md
index 89830276..e2d944b3 100644
--- a/README.md
+++ b/README.md
@@ -121,6 +121,7 @@ AZURE_OPENAI_API_KEY: 'Azure OpenAI API Key Here if using Azure OpenAI Model (op
AZURE_OPENAI_ENDPOINT: 'Azure OpenAI Endpoint Here if using Azure OpenAI Model (optional)'
AZURE_OPENAI_DEPLOYMENT: 'Azure OpenAI Deployment Here if using Azure OpenAI Model (optional)'
AZURE_OPENAI_API_VERSION: 'Azure OpenAI API Version Here if using Azure OpenAI Model (optional)'
+OPENAI_API_BASE_URL: 'LLM base URL here if using Local or alternative api Endpoint (optional)'
```
</details>
diff --git a/sweagent/agent/models.py b/sweagent/agent/models.py
index 9815905a..b4edf516 100644
--- a/sweagent/agent/models.py
+++ b/sweagent/agent/models.py
@@ -227,7 +227,8 @@ class OpenAIModel(BaseModel):
self.api_model = cfg["AZURE_OPENAI_DEPLOYMENT"]
self.client = AzureOpenAI(api_key=cfg["AZURE_OPENAI_API_KEY"], azure_endpoint=cfg["AZURE_OPENAI_ENDPOINT"], api_version=cfg.get("AZURE_OPENAI_API_VERSION", "2024-02-01"))
else:
- self.client = OpenAI(api_key=cfg["OPENAI_API_KEY"])
+ api_base_url: Optional[str] = cfg.get("OPENAI_API_BASE_URL", None)
+ self.client = OpenAI(api_key=cfg["OPENAI_API_KEY"], base_url=api_base_url)
def history_to_messages(
self, history: list[dict[str, str]], is_demonstration: bool = False