diff --git a/docker-compose.common.yml b/docker-compose.common.yml index 39092867f..f7570fbc5 100644 --- a/docker-compose.common.yml +++ b/docker-compose.common.yml @@ -22,6 +22,7 @@ services: - SECRET_MANAGER_TYPE=FILE - SECRET_MANAGER_DIRECTORY=/state - DATABASE_CONNECTION_STRING=sqlite:////state/db.sqlite3?check_same_thread=False + - OPENAI_API_URL=$OPENAI_API_URL - OPENAI_API_KEY=$OPENAI_API_KEY - PUSHER_APP_ID=1 - PUSHER_APP_KEY=keepappkey diff --git a/docs/deployment/configuration.mdx b/docs/deployment/configuration.mdx index ddf404912..d598fb612 100644 --- a/docs/deployment/configuration.mdx +++ b/docs/deployment/configuration.mdx @@ -135,6 +135,7 @@ OpenAPI configuration is used for integrating with OpenAI services. These settin | Env var | Purpose | Required | Default Value | Valid options | |:-------------------:|:-------:|:----------:|:-------------:|:-------------:| | **OPENAI_API_KEY** | API key for OpenAI services | No | None | Valid OpenAI API key | +| **OPENAI_API_URL** | URL for OpenAI API. It's need for use yourself LOCAL LLM instead OpenAi LLM. | No | None | Valid OpenAI API url | ### Posthog diff --git a/ee/experimental/generative_utils.py b/ee/experimental/generative_utils.py index 5689eb7c0..6c7c85a47 100644 --- a/ee/experimental/generative_utils.py +++ b/ee/experimental/generative_utils.py @@ -29,6 +29,14 @@ def generate_incident_summary( ) return "" + if "OPENAI_API_URL" not in os.environ: + logger.error( + "OpenAI API url is not set. You use OpenAi models.", + extra={"algorithm": SUMMARY_GENERATOR_VERBOSE_NAME, + "incident_id": incident.id, "tenant_id": incident.tenant_id} + ) + return "" + if not generate_summary: generate_summary = os.environ.get("GENERATE_INCIDENT_SUMMARY", "True") @@ -148,6 +156,14 @@ def generate_incident_name(incident: Incident, generate_name: str = None, max_na ) return "" + if "OPENAI_API_URL" not in os.environ: + logger.error( + "OpenAI API url is not set. You use OpenAi models.", + extra={"algorithm": SUMMARY_GENERATOR_VERBOSE_NAME, + "incident_id": incident.id, "tenant_id": incident.tenant_id} + ) + return "" + if not generate_name: generate_name = os.environ.get("GENERATE_INCIDENT_NAME", "True") @@ -164,7 +180,10 @@ def generate_incident_name(incident: Incident, generate_name: str = None, max_na "MAX_NAME_LENGTH", MAX_NAME_LENGTH) try: - client = OpenAI(api_key=os.environ["OPENAI_API_KEY"]) + client = OpenAI( + api_key=os.environ["OPENAI_API_KEY"], + base_url=os.environ["OPENAI_API_URL"] + ) incident = get_incident_by_id(incident.tenant_id, incident.id)