forked from phoenix-oss/llama-stack-mirror
Add API keys to AgenticSystemConfig instead of relying on dotenv (#33)
This commit is contained in:
parent
face3ceff1
commit
ab0a24f333
4 changed files with 17 additions and 9 deletions
|
@ -47,6 +47,7 @@ async def get_provider_impl(config: AgenticSystemConfig, deps: Dict[Api, Provide
|
|||
), f"Unexpected config type: {type(config)}"
|
||||
|
||||
impl = MetaReferenceAgenticSystemImpl(
|
||||
config,
|
||||
deps[Api.inference],
|
||||
deps[Api.safety],
|
||||
)
|
||||
|
@ -58,7 +59,10 @@ AGENT_INSTANCES_BY_ID = {}
|
|||
|
||||
|
||||
class MetaReferenceAgenticSystemImpl(AgenticSystem):
|
||||
def __init__(self, inference_api: Inference, safety_api: Safety):
|
||||
def __init__(
|
||||
self, config: AgenticSystemConfig, inference_api: Inference, safety_api: Safety
|
||||
):
|
||||
self.config = config
|
||||
self.inference_api = inference_api
|
||||
self.safety_api = safety_api
|
||||
|
||||
|
@ -77,9 +81,15 @@ class MetaReferenceAgenticSystemImpl(AgenticSystem):
|
|||
for dfn in cfg.available_tools:
|
||||
if isinstance(dfn.tool_name, BuiltinTool):
|
||||
if dfn.tool_name == BuiltinTool.wolfram_alpha:
|
||||
tool = WolframAlphaTool(os.environ.get("WOLFRAM_ALPHA_API_KEY"))
|
||||
key = self.config.wolfram_api_key
|
||||
if not key:
|
||||
raise ValueError("Wolfram API key not defined in config")
|
||||
tool = WolframAlphaTool(key)
|
||||
elif dfn.tool_name == BuiltinTool.brave_search:
|
||||
tool = BraveSearchTool(os.environ.get("BRAVE_SEARCH_API_KEY"))
|
||||
key = self.config.brave_search_api_key
|
||||
if not key:
|
||||
raise ValueError("Brave API key not defined in config")
|
||||
tool = BraveSearchTool(key)
|
||||
elif dfn.tool_name == BuiltinTool.code_interpreter:
|
||||
tool = CodeInterpreterTool()
|
||||
elif dfn.tool_name == BuiltinTool.photogen:
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
# the root directory of this source tree.
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class AgenticSystemConfig(BaseModel):
|
||||
# placeholder, no separate configuration is needed for now
|
||||
pass
|
||||
brave_search_api_key: Optional[str] = None
|
||||
wolfram_api_key: Optional[str] = None
|
||||
|
|
|
@ -26,7 +26,6 @@ from .datatypes import (
|
|||
# `llama-toolchain` is automatically installed by the installation script.
|
||||
SERVER_DEPENDENCIES = [
|
||||
"fastapi",
|
||||
"python-dotenv",
|
||||
"uvicorn",
|
||||
]
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ from typing import (
|
|||
import fire
|
||||
import httpx
|
||||
import yaml
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from fastapi import FastAPI, HTTPException, Request, Response
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
|
@ -42,8 +41,6 @@ from .dynamic import instantiate_client, instantiate_provider
|
|||
|
||||
from .registry import resolve_distribution_spec
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
def is_async_iterator_type(typ):
|
||||
if hasattr(typ, "__origin__"):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue