mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-27 18:50:41 +00:00
# What does this PR do? - Configured ruff linter to automatically fix import sorting issues. - Set --exit-non-zero-on-fix to ensure non-zero exit code when fixes are applied. - Enabled the 'I' selection to focus on import-related linting rules. - Ran the linter, and formatted all codebase imports accordingly. - Removed the black dep from the "dev" group since we use ruff Signed-off-by: Sébastien Han <seb@redhat.com> [//]: # (If resolving an issue, uncomment and update the line below) [//]: # (Closes #[issue-number]) ## Test Plan [Describe the tests you ran to verify your changes with result summaries. *Provide clear instructions so the plan can be easily re-executed.*] [//]: # (## Documentation) [//]: # (- [ ] Added a Changelog entry if the change is significant) Signed-off-by: Sébastien Han <seb@redhat.com>
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
# 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 Optional
|
|
|
|
from llama_stack_client import LlamaStackClient
|
|
|
|
|
|
class LlamaStackApi:
|
|
def __init__(self):
|
|
self.client = LlamaStackClient(
|
|
base_url=os.environ.get("LLAMA_STACK_ENDPOINT", "http://localhost:8321"),
|
|
provider_data={
|
|
"fireworks_api_key": os.environ.get("FIREWORKS_API_KEY", ""),
|
|
"together_api_key": os.environ.get("TOGETHER_API_KEY", ""),
|
|
"sambanova_api_key": os.environ.get("SAMBANOVA_API_KEY", ""),
|
|
"openai_api_key": os.environ.get("OPENAI_API_KEY", ""),
|
|
},
|
|
)
|
|
|
|
def run_scoring(self, row, scoring_function_ids: list[str], scoring_params: Optional[dict]):
|
|
"""Run scoring on a single row"""
|
|
if not scoring_params:
|
|
scoring_params = {fn_id: None for fn_id in scoring_function_ids}
|
|
return self.client.scoring.score(input_rows=[row], scoring_functions=scoring_params)
|
|
|
|
|
|
llama_stack_api = LlamaStackApi()
|