{"id":13878169,"url":"https://github.com/alchaplinsky/hugging-face","last_synced_at":"2025-04-23T02:50:47.571Z","repository":{"id":165649564,"uuid":"641059305","full_name":"alchaplinsky/hugging-face","owner":"alchaplinsky","description":"Ruby client for Hugging Face API","archived":false,"fork":false,"pushed_at":"2025-04-02T17:38:00.000Z","size":67,"stargazers_count":43,"open_issues_count":1,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-17T18:23:41.531Z","etag":null,"topics":["ai","api-client","artificial-intelligence","huggingface","machine-learning","ml","ruby"],"latest_commit_sha":null,"homepage":"https://huggingface.co/inference-api","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alchaplinsky.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-15T17:35:19.000Z","updated_at":"2025-04-02T17:38:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"818f4c7b-e8e5-458f-af85-d4bc41b9e07e","html_url":"https://github.com/alchaplinsky/hugging-face","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2Fhugging-face","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2Fhugging-face/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2Fhugging-face/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alchaplinsky%2Fhugging-face/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alchaplinsky","download_url":"https://codeload.github.com/alchaplinsky/hugging-face/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250360248,"owners_count":21417717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","api-client","artificial-intelligence","huggingface","machine-learning","ml","ruby"],"created_at":"2024-08-06T08:01:41.723Z","updated_at":"2025-04-23T02:50:47.549Z","avatar_url":"https://github.com/alchaplinsky.png","language":"Ruby","readme":"# hugging-face\n\n🤗 HuggingFace API wrapper for Ruby\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n```\n$ bundle add hugging-face\n```\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n```\n$ gem install hugging-face\n```\n\n## Usage\n\n\n### Inference API\n\nThe inference API is a free Machine Learning API from Hugging Face. It is meant for prototyping and not production use, see below for Inference Endpoints, the product for use with production LLMs.\n\n```ruby\nrequire \"hugging_face\"\n```\n\nInstantiate a HuggingFace Inference API client:\n\n```ruby\nclient = HuggingFace::InferenceApi.new(api_token: ENV['HUGGING_FACE_API_TOKEN'])\n```\n\nQuestion answering:\n\n```ruby\nclient.question_answering(\n  question: 'What is my name?',\n  context: 'I am the only child. My father named his son John.'\n)\n```\n\nText generation:\n\n```ruby\nclient.text_generation(input: 'Can you please let us know more details about your ')\n```\n\nSummarization:\n\n```ruby\nclient.summarization(input: 'The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930.')\n```\n\nEmbedding:\n\n```ruby\nclient.embedding(input: ['How to build a ruby gem?', 'How to install ruby gem?'])\n```\n\nSentiment:\n\n```ruby\nclient.sentiment(input: ['My life sucks', 'Life is a miracle'])\n```\n\n### Inference Endpoints\n\nWith this same gem, you can also access endpoints, which are best described by Hugging Face: \"[Inference Endpoints](https://huggingface.co/docs/inference-endpoints/index) provides a secure production solution to easily deploy models on a dedicated and autoscaling infrastructure managed by Hugging Face. An Inference Endpoint is built from a model from the Hub.\"\n\nOnce you've created an endpoint by choosing a model and desired infrastructure, you'll be given an endpoint URL, something like: https://eyic1edp3ah0g5ln.us-east-1.aws.endpoints.huggingface.cloud\n\nYou'll need your token to access your endpoint if you've chosen for it to be protected. You can also choose to have a public endpoint.\n\nSince you choose the LLM task in your endpoint config (e.g. Text Classification, Summarisation, Question answering), there is no need to pass that argument.\n\nTo access from the gem. instantiate a HuggingFace Endpoint API client:\n\n```ruby\nendpoint = HuggingFace::EndpointsApi.new(api_token: ENV['HUGGING_FACE_API_TOKEN'])\n```\n\nExample with input from question answering task:\n\n```ruby\nendpoint.request(endpoint_url: \"https://your-end-point.us-east-1.aws.endpoints.huggingface.cloud\", input: { context: some_text, question: question } \n```\n\nExample call to an endpoint configured for summarisation, including passing params:\n\n```ruby\nendpoint.request(endpoint_url: \"https://your-end-point.us-east-1.aws.endpoints.huggingface.cloud\", input: some_text, params: { min_length:  32, max_length: 64 } )\n```\n\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/alchaplinsky/hugging-face. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/alchaplinsky/hugging-face/blob/main/CODE_OF_CONDUCT.md).\n\n## Code of Conduct\n\nEveryone interacting in the HuggingFace project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/alchaplinsky/hugging-face/blob/main/CODE_OF_CONDUCT.md).\n\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falchaplinsky%2Fhugging-face","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falchaplinsky%2Fhugging-face","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falchaplinsky%2Fhugging-face/lists"}