forked from phoenix-oss/llama-stack-mirror
# What does this PR do? This PR adds SambaNova as one of the Provider - Add SambaNova as a provider ## Test Plan Test the functional command ``` pytest -s -v --providers inference=sambanova llama_stack/providers/tests/inference/test_embeddings.py llama_stack/providers/tests/inference/test_prompt_adapter.py llama_stack/providers/tests/inference/test_text_inference.py llama_stack/providers/tests/inference/test_vision_inference.py --env SAMBANOVA_API_KEY=<sambanova-api-key> ``` Test the distribution template: ``` # Docker LLAMA_STACK_PORT=5001 docker run -it -p $LLAMA_STACK_PORT:$LLAMA_STACK_PORT \ llamastack/distribution-sambanova \ --port $LLAMA_STACK_PORT \ --env SAMBANOVA_API_KEY=$SAMBANOVA_API_KEY # Conda llama stack build --template sambanova --image-type conda llama stack run ./run.yaml \ --port $LLAMA_STACK_PORT \ --env SAMBANOVA_API_KEY=$SAMBANOVA_API_KEY ``` ## Source [SambaNova API Documentation](https://cloud.sambanova.ai/apis) ## Before submitting - [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case). - [Y] Ran pre-commit to handle lint / formatting issues. - [Y] Read the [contributor guideline](https://github.com/meta-llama/llama-stack/blob/main/CONTRIBUTING.md), Pull Request section? - [Y] Updated relevant documentation. - [Y ] Wrote necessary unit or integration tests. --------- Co-authored-by: Ashwin Bharambe <ashwin.bharambe@gmail.com>
37 lines
1.2 KiB
Python
37 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()
|