portkey integration v1

This commit is contained in:
siddharthsambharia-portkey 2024-12-20 17:21:54 +05:30
parent c8be0bf1c9
commit 7ece0d4d8b
6 changed files with 332 additions and 0 deletions

View file

@ -0,0 +1,32 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
import os
from typing import Any, Dict, Optional
from llama_models.schema_utils import json_schema_type
from pydantic import BaseModel, Field
DEFAULT_BASE_URL = "https://api.portkey.ai/v1"
@json_schema_type
class PortkeyImplConfig(BaseModel):
base_url: str = Field(
default=os.environ.get("PORTKEY_BASE_URL", DEFAULT_BASE_URL),
description="Base URL for the Portkey API",
)
api_key: Optional[str] = Field(
default=os.environ.get("PORTKEY_API_KEY"),
description="Portkey API Key",
)
@classmethod
def sample_run_config(cls, **kwargs) -> Dict[str, Any]:
return {
"base_url": DEFAULT_BASE_URL,
"api_key": "${env.PORTKEY_API_KEY}",
}