Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
3 changes: 1 addition & 2 deletions comps/cores/mega/micro_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@

def endpoint_path(self, model=None):
if self.api_key:
model_endpoint = model.split("/")[1]
return f"{self.host}/{model_endpoint}{self.endpoint}"
return f"{self.host}{self.endpoint}"

Check warning on line 162 in comps/cores/mega/micro_service.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/mega/micro_service.py#L162

Added line #L162 was not covered by tests
else:
return f"{self.protocol}://{self.host}:{self.port}{self.endpoint}"

Expand Down
7 changes: 6 additions & 1 deletion comps/cores/mega/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ async def execute(
stream=True,
timeout=2000,
)

else:
response = requests.post(
url=endpoint,
Expand Down Expand Up @@ -367,7 +368,11 @@ def generate():
if ENABLE_OPEA_TELEMETRY
else contextlib.nullcontext()
):
response = await session.post(endpoint, json=input_data)
response = await session.post(
endpoint,
json=input_data,
headers={"Content-type": "application/json", "Authorization": f"Bearer {access_token}"},
)

if response.content_type == "audio/wav":
audio_data = await response.read()
Expand Down
12 changes: 9 additions & 3 deletions comps/llms/src/doc-summarization/integrations/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
TOKEN_URL = os.getenv("TOKEN_URL")
CLIENTID = os.getenv("CLIENTID")
CLIENT_SECRET = os.getenv("CLIENT_SECRET")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
MAX_INPUT_TOKENS = int(os.getenv("MAX_INPUT_TOKENS", 2048))
MAX_TOTAL_TOKENS = int(os.getenv("MAX_TOTAL_TOKENS", 4096))

Expand Down Expand Up @@ -67,9 +68,14 @@ class OpeaDocSum(OpeaComponent):

def __init__(self, name: str, description: str, config: dict = None):
super().__init__(name, ServiceType.LLM.name.lower(), description, config)
self.access_token = (
get_access_token(TOKEN_URL, CLIENTID, CLIENT_SECRET) if TOKEN_URL and CLIENTID and CLIENT_SECRET else None
)
if OPENAI_API_KEY:
self.access_token = OPENAI_API_KEY
else:
self.access_token = (
get_access_token(TOKEN_URL, CLIENTID, CLIENT_SECRET)
if TOKEN_URL and CLIENTID and CLIENT_SECRET
else None
)
self.llm_endpoint = get_llm_endpoint()
self.tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
health_status = self.check_health()
Expand Down
Loading