Skip to content

Commit

Permalink
update for use local LLM
Browse files Browse the repository at this point in the history
  • Loading branch information
a.gorlanov committed Nov 22, 2024
1 parent 4463c01 commit e6190b1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions docker-compose.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/deployment/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion ee/experimental/generative_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand All @@ -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)

Expand Down

0 comments on commit e6190b1

Please sign in to comment.