Hugging Face
Models
Datasets
Spaces
Posts
Docs
Enterprise
Pricing
Log In
Sign Up
Ashita
ashesashes
Follow
0 followers
Β·
1 following
AI & ML interests
None yet
Recent Activity
updated
a model
about 1 month ago
ashesashes/yt-thumbs
updated
a model
about 1 month ago
ashesashes/yt-thumbs
reacted
to
andrewrreed
's
post
with β€οΈ
12 months ago
π It's now easier than ever to switch from OpenAI to open LLMs Hugging Face's TGI now supports an OpenAI compatible Chat Completion API This means you can transition code that uses OpenAI client libraries (or frameworks like LangChain π¦ and LlamaIndex π¦) to run open models by changing just two lines of code π€ β Here's how: ``` from openai import OpenAI # initialize the client but point it to TGI client = OpenAI( base_url="<ENDPOINT_URL>" + "/v1/", # replace with your endpoint url api_key="<HF_API_TOKEN>", # replace with your token ) chat_completion = client.chat.completions.create( model="tgi", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Why is open-source software important?"}, ], stream=True, max_tokens=500 ) # iterate and print stream for message in chat_completion: print(message.choices[0].delta.content, end="") ``` π Blog post β‘ https://huggingface.co/blog/tgi-messages-api π TGI docs β‘ https://huggingface.co/docs/text-generation-inference/en/messages_api
View all activity
Organizations
None yet
models
1
ashesashes/yt-thumbs
Text-to-Image
β’
Updated
Dec 15, 2024
β’
datasets
None public yet