mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 12:20:38 +08:00
Merge pull request #40 from Codium-ai/feature/support_azure_openai
Add Azure OpenAI support
This commit is contained in:
@ -14,6 +14,13 @@ class AiHandler:
|
|||||||
openai.api_key = settings.openai.key
|
openai.api_key = settings.openai.key
|
||||||
if settings.get("OPENAI.ORG", None):
|
if settings.get("OPENAI.ORG", None):
|
||||||
openai.organization = settings.openai.org
|
openai.organization = settings.openai.org
|
||||||
|
self.deployment_id = settings.get("OPENAI.DEPLOYMENT_ID", None)
|
||||||
|
if settings.get("OPENAI.API_TYPE", None):
|
||||||
|
openai.api_type = settings.openai.api_type
|
||||||
|
if settings.get("OPENAI.API_VERSION", None):
|
||||||
|
openai.engine = settings.openai.api_version
|
||||||
|
if settings.get("OPENAI.API_BASE", None):
|
||||||
|
openai.api_base = settings.openai.api_base
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
raise ValueError("OpenAI key is required") from e
|
raise ValueError("OpenAI key is required") from e
|
||||||
|
|
||||||
@ -23,6 +30,7 @@ class AiHandler:
|
|||||||
try:
|
try:
|
||||||
response = await openai.ChatCompletion.acreate(
|
response = await openai.ChatCompletion.acreate(
|
||||||
model=model,
|
model=model,
|
||||||
|
deployment_id=self.deployment_id,
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "system", "content": system},
|
{"role": "system", "content": system},
|
||||||
{"role": "user", "content": user}
|
{"role": "user", "content": user}
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
[openai]
|
[openai]
|
||||||
key = "<API_KEY>" # Acquire through https://platform.openai.com
|
key = "<API_KEY>" # Acquire through https://platform.openai.com
|
||||||
org = "<ORGANIZATION>" # Optional, may be commented out.
|
org = "<ORGANIZATION>" # Optional, may be commented out.
|
||||||
|
# Uncomment the following for Azure OpenAI
|
||||||
|
#api_type = "azure"
|
||||||
|
#api_version = '2023-05-15' # Check Azure documentation for the current API version
|
||||||
|
#api_base = "<API_BASE>" # The base URL for your Azure OpenAI resource. e.g. "https://<your resource name>.openai.azure.com"
|
||||||
|
#deployment_id = "<DEPLOYMENT_ID>" # The deployment name you chose when you deployed the engine
|
||||||
|
|
||||||
[github]
|
[github]
|
||||||
# ---- Set the following only for deployment type == "user"
|
# ---- Set the following only for deployment type == "user"
|
||||||
|
Reference in New Issue
Block a user