From f3914c87d37415a615922fcfb786e7b853c9389d Mon Sep 17 00:00:00 2001 From: Jongseob Jeon Date: Thu, 14 Nov 2024 13:47:57 +0800 Subject: [PATCH] Update code blocks huggingface.md (#6737) --- docs/my-website/docs/providers/huggingface.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/my-website/docs/providers/huggingface.md b/docs/my-website/docs/providers/huggingface.md index 4620a6c5d..5297a688b 100644 --- a/docs/my-website/docs/providers/huggingface.md +++ b/docs/my-website/docs/providers/huggingface.md @@ -37,7 +37,7 @@ os.environ["HUGGINGFACE_API_KEY"] = "huggingface_api_key" messages = [{ "content": "There's a llama in my garden 😱 What should I do?","role": "user"}] # e.g. Call 'https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct' from Serverless Inference API -response = litellm.completion( +response = completion( model="huggingface/meta-llama/Meta-Llama-3.1-8B-Instruct", messages=[{ "content": "Hello, how are you?","role": "user"}], stream=True @@ -165,14 +165,14 @@ Steps to use ```python import os -import litellm +from litellm import completion os.environ["HUGGINGFACE_API_KEY"] = "" # TGI model: Call https://huggingface.co/glaiveai/glaive-coder-7b # add the 'huggingface/' prefix to the model to set huggingface as the provider # set api base to your deployed api endpoint from hugging face -response = litellm.completion( +response = completion( model="huggingface/glaiveai/glaive-coder-7b", messages=[{ "content": "Hello, how are you?","role": "user"}], api_base="https://wjiegasee9bmqke2.us-east-1.aws.endpoints.huggingface.cloud" @@ -383,6 +383,8 @@ def default_pt(messages): #### Custom prompt templates ```python +import litellm + # Create your own custom prompt template works litellm.register_prompt_template( model="togethercomputer/LLaMA-2-7B-32K",