Whitepaper
Docs
Sign In
Function
Function
pipe
v1.8.0
SambaNova
Function ID
sambanova
Creator
@olof
Downloads
25+
https://cloud.sambanova.ai
Get
README
No README available
Function Code
Show
""" title: SambaNova description: https://cloud.sambanova.ai author: Olof Larsson author_url: https://olof.tech/sambanova-for-open-webui version: 1.8.0 license: MIT """ import os import requests from typing import List, Union, Generator, Iterator, Optional from pydantic import BaseModel, Field # Learn more here: # https://olof.tech/sambanova-for-open-webui class Pipe: class Valves(BaseModel): API_KEY: str = Field( default=os.getenv("SAMBANOVA_API_KEY", ""), description="Get your key here: https://cloud.sambanova.ai", ) def __init__(self): self.type = "manifold" self.id = "sambanova" self.name = "sambanova/" self.valves = self.Valves() self.base_url = "https://api.sambanova.ai/v1" # Q: Why hard-code the model ids? # A: Because it yields the best performance. OpenWebUI is very sensitive to slowness here. It impacts page loads. def get_model_ids(self): # How to update: # Go to https://docs.sambanova.ai/cloud/docs/get-started/supported-models # Use the javascript below: # console.log(JSON.stringify([...document.querySelectorAll('code')].map(el => el.textContent).sort(), null, " ")) return [ "DeepSeek-R1", "DeepSeek-R1-Distill-Llama-70B", "DeepSeek-V3-0324", "E5-Mistral-7B-Instruct", "Llama-3.1-Swallow-70B-Instruct-v0.3", "Llama-3.1-Swallow-8B-Instruct-v0.3", "Llama-3.1-Tulu-3-405B", "Llama-3.2-11B-Vision-Instruct", "Llama-3.2-90B-Vision-Instruct", "Llama-4-Maverick-17B-128E-Instruct", "Llama-4-Scout-17B-16E-Instruct", "Meta-Llama-3.1-405B-Instruct", "Meta-Llama-3.1-70B-Instruct", "Meta-Llama-3.1-8B-Instruct", "Meta-Llama-3.2-1B-Instruct", "Meta-Llama-3.2-3B-Instruct", "Meta-Llama-3.3-70B-Instruct", "Meta-Llama-Guard-3-8B", "QwQ-32B", "Qwen2-Audio-7B-Instruct", "Qwen2.5-72B-Instruct", "Qwen2.5-Coder-32B-Instruct", ] def pipes(self) -> List[dict]: model_ids = self.get_model_ids() return [{"id": model_id, "name": model_id} for model_id in model_ids] def pipe( self, body: dict, ) -> Union[str, Generator, Iterator]: body["model"] = body["model"].removeprefix(self.id + ".") try: r = requests.post( url=f"{self.base_url}/chat/completions", json=body, headers={ "Content-Type": "application/json", "Authorization": f"Bearer {self.valves.API_KEY}", }, stream=True, ) r.raise_for_status() if body["stream"]: return r.iter_lines() else: return r.json() except Exception as e: return f"Error: {e}"