Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with downstream #80

Merged
merged 5 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ols/src/llms/providers/azure_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def default_params(self) -> dict[str, Any]:
"temperature": 0.01,
"max_tokens": 512,
"verbose": False,
"http_client": self._construct_httpx_client(False),
}

if self.credentials is not None:
Expand Down
1 change: 1 addition & 0 deletions ols/src/llms/providers/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def default_params(self) -> dict[str, Any]:
"temperature": 0.01,
"max_tokens": 512,
"verbose": False,
"http_client": self._construct_httpx_client(False),
}

def load(self) -> LLM:
Expand Down
10 changes: 10 additions & 0 deletions ols/src/llms/providers/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ProviderParameter:
ProviderParameter("temperature", float),
ProviderParameter("max_tokens", int),
ProviderParameter("verbose", bool),
ProviderParameter("http_client", httpx.Client),
}

OpenAIParameters = {
Expand All @@ -66,6 +67,7 @@ class ProviderParameter:
ProviderParameter("temperature", float),
ProviderParameter("max_tokens", int),
ProviderParameter("verbose", bool),
ProviderParameter("http_client", httpx.Client),
}

RHOAIVLLMParameters = {
Expand Down Expand Up @@ -317,3 +319,11 @@ def _override_params(self, params: dict[Any, Any]) -> dict[Any, Any]:
updated_params = {**updated_params, **config.dev_config.llm_params}

return updated_params

def _construct_httpx_client(
self, use_custom_certificate_store: bool
) -> httpx.Client:
"""Construct HTTPX client instance to be used to communicate with LLM."""
if use_custom_certificate_store:
return httpx.Client(verify=self.provider_config.certificates_store)
return httpx.Client()
3 changes: 1 addition & 2 deletions ols/src/llms/providers/rhelai_vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import logging
from typing import Any, Optional

import httpx
from langchain.llms.base import LLM
from langchain_openai import ChatOpenAI

Expand Down Expand Up @@ -48,7 +47,7 @@ def default_params(self) -> dict[str, Any]:
"temperature": 0.01,
"max_tokens": 512,
"verbose": False,
"http_client": httpx.Client(verify=self.provider_config.certificates_store),
"http_client": self._construct_httpx_client(True),
}

def load(self) -> LLM:
Expand Down
3 changes: 1 addition & 2 deletions ols/src/llms/providers/rhoai_vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import logging
from typing import Any, Optional

import httpx
from langchain.llms.base import LLM
from langchain_openai import ChatOpenAI

Expand Down Expand Up @@ -48,7 +47,7 @@ def default_params(self) -> dict[str, Any]:
"temperature": 0.01,
"max_tokens": 512,
"verbose": False,
"http_client": httpx.Client(verify=self.provider_config.certificates_store),
"http_client": self._construct_httpx_client(True),
}

def load(self) -> LLM:
Expand Down
7 changes: 0 additions & 7 deletions ols/src/prompts/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@

from ols.constants import SUBJECT_ALLOWED, SUBJECT_REJECTED

# Note::
# Right now templates are somewhat alligned to make granite work better.
# GPT still works well with this. Ideally we should have model specific tags.
# For history we can laverage ChatPromptTemplate from langchain,
# but that is not done as granite was adding role tags like `Human:` in the response.
# With PromptTemplate, we have more control how we want to structure the prompt.

QUERY_SYSTEM_INSTRUCTION = """
You are OpenShift Lightspeed - an intelligent assistant for question-answering tasks \
related to the OpenShift container orchestration platform.
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-container.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Version
OLS_VERSION=v0.0.0
OLS_VERSION=v0.2.1

# To build container for local use
if [ -z "$OLS_NO_IMAGE_CACHE" ]; then
Expand Down
8 changes: 4 additions & 4 deletions tests/config/operator_install/imagedigestmirrorset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ metadata:
name: openshift-lightspeed-prod-to-ci
spec:
imageDigestMirrors:
- source: registry.redhat.io/openshift-lightspeed-beta/lightspeed-rhel9-operator
- source: registry.redhat.io/openshift-lightspeed-tech-preview/lightspeed-rhel9-operator
mirrors:
- quay.io/redhat-user-workloads/crt-nshift-lightspeed-tenant/ols/lightspeed-operator
- source: registry.redhat.io/openshift-lightspeed-beta/lightspeed-operator-bundle
- source: registry.redhat.io/openshift-lightspeed-tech-preview/lightspeed-operator-bundle
mirrors:
- quay.io/redhat-user-workloads/crt-nshift-lightspeed-tenant/ols/bundle
- source: registry.redhat.io/openshift-lightspeed-beta/lightspeed-service-api-rhel9
- source: registry.redhat.io/openshift-lightspeed-tech-preview/lightspeed-service-api-rhel9
mirrors:
- quay.io/redhat-user-workloads/crt-nshift-lightspeed-tenant/ols/lightspeed-service
- source: registry.redhat.io/openshift-lightspeed-beta/lightspeed-console-plugin-rhel9
- source: registry.redhat.io/openshift-lightspeed-tech-preview/lightspeed-console-plugin-rhel9
mirrors:
- quay.io/redhat-user-workloads/crt-nshift-lightspeed-tenant/ols/lightspeed-console
8 changes: 8 additions & 0 deletions tests/unit/llms/providers/test_azure_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time
from unittest.mock import patch

import httpx
import pytest
from azure.core.credentials import AccessToken
from langchain_openai import AzureChatOpenAI
Expand Down Expand Up @@ -211,6 +212,13 @@ def test_basic_interface(provider_config):

assert azure_openai.default_params["azure_endpoint"] == "test_url"

# check the HTTP client parameter
assert "http_client" in azure_openai.default_params
assert azure_openai.default_params["http_client"] is not None

client = azure_openai.default_params["http_client"]
assert isinstance(client, httpx.Client)


def test_credentials_in_directory_handling(provider_config_credentials_directory):
"""Test that credentials in directory is handled as expected."""
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/llms/providers/test_openai.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Unit tests for OpenAI provider."""

import httpx
import pytest
from langchain_openai.chat_models.base import ChatOpenAI

Expand Down Expand Up @@ -81,6 +82,13 @@ def test_basic_interface(provider_config):
assert "model" in openai.default_params
assert "max_tokens" in openai.default_params

# check the HTTP client parameter
assert "http_client" in openai.default_params
assert openai.default_params["http_client"] is not None

client = openai.default_params["http_client"]
assert isinstance(client, httpx.Client)


def test_params_handling(provider_config):
"""Test that not allowed parameters are removed before model init."""
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/llms/providers/test_rhelai_vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os

import httpx
import pytest
from langchain_openai.chat_models.base import ChatOpenAI

Expand Down Expand Up @@ -99,9 +100,14 @@ def test_basic_interface(provider_config, fake_certifi_store):
assert "base_url" in rhelai_vllm.default_params
assert "model" in rhelai_vllm.default_params
assert "max_tokens" in rhelai_vllm.default_params

# check the HTTP client parameter
assert "http_client" in rhelai_vllm.default_params
assert rhelai_vllm.default_params["http_client"] is not None

client = rhelai_vllm.default_params["http_client"]
assert isinstance(client, httpx.Client)


def test_params_handling(provider_config, fake_certifi_store):
"""Test that not allowed parameters are removed before model init."""
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/llms/providers/test_rhoai_vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os

import httpx
import pytest
from langchain_openai.chat_models.base import ChatOpenAI

Expand Down Expand Up @@ -99,9 +100,14 @@ def test_basic_interface(provider_config, fake_certifi_store):
assert "base_url" in rhoai_vllm.default_params
assert "model" in rhoai_vllm.default_params
assert "max_tokens" in rhoai_vllm.default_params

# check the HTTP client parameter
assert "http_client" in rhoai_vllm.default_params
assert rhoai_vllm.default_params["http_client"] is not None

client = rhoai_vllm.default_params["http_client"]
assert isinstance(client, httpx.Client)


def test_params_handling(provider_config, fake_certifi_store):
"""Test that not allowed parameters are removed before model init."""
Expand Down
Loading