LiteLLMは、LLMへのアクセス、入力の変換、例外のマッピングのための統一されたインターフェースを提供するオープンソースのPythonライブラリです。

コード例

from litellm import completion
import os

os.environ['SAMBANOVA_API_KEY'] = ""
response = completion(
    model="sambanova/Meta-Llama-3.1-8B-Instruct",
    messages=[
        {
            "role": "user",
            "content": "What do you know about sambanova.ai. Give your response in json format",
        }
    ],
    max_tokens=10,
    response_format={ "type": "json_object" },
    stop=["\n\n"],
    temperature=0.2,
    top_p=0.9,
    tool_choice="auto",
    tools=[],
    user="user",
)
print(response)
詳しくはLiteLLMのドキュメントで、より多くの例やLiteLLM Proxyサーバーでの使用方法をご確認ください。