mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-29 15:23:51 +00:00
API Keys passed from Client instead of distro configuration
This commit is contained in:
parent
a11d92601b
commit
0df4d9c9bd
5 changed files with 16 additions and 21 deletions
|
@ -53,6 +53,7 @@ class SearchToolDefinition(ToolDefinitionCommon):
|
||||||
type: Literal[AgenticSystemTool.brave_search.value] = (
|
type: Literal[AgenticSystemTool.brave_search.value] = (
|
||||||
AgenticSystemTool.brave_search.value
|
AgenticSystemTool.brave_search.value
|
||||||
)
|
)
|
||||||
|
api_key: str
|
||||||
engine: SearchEngineType = SearchEngineType.brave
|
engine: SearchEngineType = SearchEngineType.brave
|
||||||
remote_execution: Optional[RestAPIExecutionConfig] = None
|
remote_execution: Optional[RestAPIExecutionConfig] = None
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@ class WolframAlphaToolDefinition(ToolDefinitionCommon):
|
||||||
type: Literal[AgenticSystemTool.wolfram_alpha.value] = (
|
type: Literal[AgenticSystemTool.wolfram_alpha.value] = (
|
||||||
AgenticSystemTool.wolfram_alpha.value
|
AgenticSystemTool.wolfram_alpha.value
|
||||||
)
|
)
|
||||||
|
api_key: str
|
||||||
remote_execution: Optional[RestAPIExecutionConfig] = None
|
remote_execution: Optional[RestAPIExecutionConfig] = None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,12 @@
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
from typing import AsyncGenerator
|
from typing import AsyncGenerator
|
||||||
|
|
||||||
import fire
|
import fire
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from termcolor import cprint
|
from termcolor import cprint
|
||||||
|
@ -22,6 +23,9 @@ from .api import * # noqa: F403
|
||||||
from .event_logger import EventLogger
|
from .event_logger import EventLogger
|
||||||
|
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
|
||||||
async def get_client_impl(config: RemoteProviderConfig, _deps):
|
async def get_client_impl(config: RemoteProviderConfig, _deps):
|
||||||
return AgenticSystemClient(config.url)
|
return AgenticSystemClient(config.url)
|
||||||
|
|
||||||
|
@ -134,8 +138,11 @@ async def run_main(host: str, port: int):
|
||||||
api = AgenticSystemClient(f"http://{host}:{port}")
|
api = AgenticSystemClient(f"http://{host}:{port}")
|
||||||
|
|
||||||
tool_definitions = [
|
tool_definitions = [
|
||||||
SearchToolDefinition(engine=SearchEngineType.bing),
|
SearchToolDefinition(
|
||||||
WolframAlphaToolDefinition(),
|
engine=SearchEngineType.bing,
|
||||||
|
api_key=os.getenv("BING_SEARCH_API_KEY"),
|
||||||
|
),
|
||||||
|
WolframAlphaToolDefinition(api_key=os.getenv("WOLFRAM_ALPHA_API_KEY")),
|
||||||
CodeInterpreterToolDefinition(),
|
CodeInterpreterToolDefinition(),
|
||||||
]
|
]
|
||||||
tool_definitions += [
|
tool_definitions += [
|
||||||
|
|
|
@ -58,19 +58,9 @@ class MetaReferenceAgenticSystemImpl(AgenticSystem):
|
||||||
builtin_tools = []
|
builtin_tools = []
|
||||||
for tool_defn in agent_config.tools:
|
for tool_defn in agent_config.tools:
|
||||||
if isinstance(tool_defn, WolframAlphaToolDefinition):
|
if isinstance(tool_defn, WolframAlphaToolDefinition):
|
||||||
key = self.config.wolfram_api_key
|
tool = WolframAlphaTool(tool_defn.api_key)
|
||||||
if not key:
|
|
||||||
raise ValueError("Wolfram API key not defined in config")
|
|
||||||
tool = WolframAlphaTool(key)
|
|
||||||
elif isinstance(tool_defn, SearchToolDefinition):
|
elif isinstance(tool_defn, SearchToolDefinition):
|
||||||
key = None
|
tool = SearchTool(tool_defn.engine, tool_defn.api_key)
|
||||||
if tool_defn.engine == SearchEngineType.brave:
|
|
||||||
key = self.config.brave_search_api_key
|
|
||||||
elif tool_defn.engine == SearchEngineType.bing:
|
|
||||||
key = self.config.bing_search_api_key
|
|
||||||
if not key:
|
|
||||||
raise ValueError("API key not defined in config")
|
|
||||||
tool = SearchTool(tool_defn.engine, key)
|
|
||||||
elif isinstance(tool_defn, CodeInterpreterToolDefinition):
|
elif isinstance(tool_defn, CodeInterpreterToolDefinition):
|
||||||
tool = CodeInterpreterTool()
|
tool = CodeInterpreterTool()
|
||||||
elif isinstance(tool_defn, PhotogenToolDefinition):
|
elif isinstance(tool_defn, PhotogenToolDefinition):
|
||||||
|
|
|
@ -4,12 +4,7 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
class MetaReferenceImplConfig(BaseModel):
|
class MetaReferenceImplConfig(BaseModel): ...
|
||||||
brave_search_api_key: Optional[str] = None
|
|
||||||
bing_search_api_key: Optional[str] = None
|
|
||||||
wolfram_api_key: Optional[str] = None
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ fire
|
||||||
httpx
|
httpx
|
||||||
huggingface-hub
|
huggingface-hub
|
||||||
llama-models>=0.0.13
|
llama-models>=0.0.13
|
||||||
|
python-dotenv
|
||||||
pydantic
|
pydantic
|
||||||
requests
|
requests
|
||||||
termcolor
|
termcolor
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue