Thomas G. Lopes commited on
Commit
a64b708
·
1 Parent(s): 0b7f1ea

some oss stuff

Browse files
.env.example DELETED
@@ -1 +0,0 @@
1
- HF_TOKEN=
 
 
CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a
6
+ harassment-free experience for everyone, regardless of age, body size, visible or invisible
7
+ disability, ethnicity, sex characteristics, gender identity and expression, level of experience,
8
+ education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or
9
+ sexual identity and orientation.
10
+
11
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and
12
+ healthy community.
13
+
14
+ ## Our Standards
15
+
16
+ Examples of behavior that contributes to a positive environment for our community include:
17
+
18
+ - Demonstrating empathy and kindness toward other people
19
+ - Being respectful of differing opinions, viewpoints, and experiences
20
+ - Giving and gracefully accepting constructive feedback
21
+ - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the
22
+ experience
23
+ - Focusing on what is best not just for us as individuals, but for the overall community
24
+
25
+ Examples of unacceptable behavior include:
26
+
27
+ - The use of sexualized language or imagery, and sexual attention or advances of any kind
28
+ - Trolling, insulting or derogatory comments, and personal or political attacks
29
+ - Public or private harassment
30
+ - Publishing others' private information, such as a physical or email address, without their
31
+ explicit permission
32
+ - Other conduct which could reasonably be considered inappropriate in a professional setting
33
+
34
+ ## Enforcement Responsibilities
35
+
36
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior
37
+ and will take appropriate and fair corrective action in response to any behavior that they deem
38
+ inappropriate, threatening, offensive, or harmful.
39
+
40
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits,
41
+ code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and
42
+ will communicate reasons for moderation decisions when appropriate.
43
+
44
+ ## Scope
45
+
46
+ This Code of Conduct applies within all community spaces, and also applies when an individual is
47
+ officially representing the community in public spaces. Examples of representing our community
48
+ include using an official e-mail address, posting via an official social media account, or acting as
49
+ an appointed representative at an online or offline event.
50
+
51
+ ## Enforcement
52
+
53
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community
54
+ leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and
55
+ investigated promptly and fairly.
56
+
57
+ All community leaders are obligated to respect the privacy and security of the reporter of any
58
+ incident.
59
+
60
+ ## Enforcement Guidelines
61
+
62
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for
63
+ any action they deem in violation of this Code of Conduct:
64
+
65
+ ### 1. Correction
66
+
67
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or
68
+ unwelcome in the community.
69
+
70
+ **Consequence**: A private, written warning from community leaders, providing clarity around the
71
+ nature of the violation and an explanation of why the behavior was inappropriate. A public apology
72
+ may be requested.
73
+
74
+ ### 2. Warning
75
+
76
+ **Community Impact**: A violation through a single incident or series of actions.
77
+
78
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people
79
+ involved, including unsolicited interaction with those enforcing the Code of Conduct, for a
80
+ specified period of time. This includes avoiding interactions in community spaces as well as
81
+ external channels like social media. Violating these terms may lead to a temporary or permanent ban.
82
+
83
+ ### 3. Temporary Ban
84
+
85
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate
86
+ behavior.
87
+
88
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the
89
+ community for a specified period of time. No public or private interaction with the people involved,
90
+ including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this
91
+ period. Violating these terms may lead to a permanent ban.
92
+
93
+ ### 4. Permanent Ban
94
+
95
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including
96
+ sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement
97
+ of classes of individuals.
98
+
99
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
100
+
101
+ ## Attribution
102
+
103
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at
104
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
105
+
106
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement
107
+ ladder][Mozilla CoC].
108
+
109
+ For answers to common questions about this code of conduct, see the FAQ at
110
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
111
+ [https://www.contributor-covenant.org/translations][translations].
112
+
113
+ [homepage]: https://www.contributor-covenant.org
114
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
115
+ [Mozilla CoC]: https://github.com/mozilla/diversity
116
+ [FAQ]: https://www.contributor-covenant.org/faq
117
+ [translations]: https://www.contributor-covenant.org/translations
CONTRIBUTING.md ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contribute to 🤗 Playground
2
+
3
+ Everyone is welcome to contribute, and we value everybody's contribution. Code
4
+ contributions are not the only way to help the community. Answering questions, helping
5
+ others, and improving the documentation are also immensely valuable.
6
+
7
+ It also helps us if you spread the word! Reference the library in blog posts
8
+ about the awesome projects it made possible, shout out on Twitter every time it has
9
+ helped you, or simply ⭐️ the repository to say thank you.
10
+
11
+ However you choose to contribute, please be mindful and respect our
12
+ [code of conduct](https://github.com/huggingface/inference-playground/blob/main/CODE_OF_CONDUCT.md).
13
+
14
+ **This guide was heavily inspired by the awesome [scikit-learn guide to contributing](https://github.com/scikit-learn/scikit-learn/blob/main/CONTRIBUTING.md).**
15
+
16
+ ## Ways to contribute
17
+
18
+ There are several ways you can contribute to 🤗 Playground:
19
+
20
+ - Fix outstanding issues with the existing code.
21
+ - Submit issues related to bugs or desired new features.
22
+ - Implement new models.
23
+ - Contribute to the examples or to the documentation.
24
+
25
+ > All contributions are equally valuable to the community. 🥰
26
+
27
+ ## Fixing outstanding issues
28
+
29
+ If you notice an issue with the existing code and have a fix in mind, feel free to [start contributing](#create-a-pull-request) and open a Pull Request!
30
+
31
+ ## Submitting a bug-related issue or feature request
32
+
33
+ Do your best to follow these guidelines when submitting a bug-related issue or a feature
34
+ request. It will make it easier for us to come back to you quickly and with good
35
+ feedback.
36
+
37
+ ### Did you find a bug?
38
+
39
+ Before you report an issue, we would really appreciate it if you could **make sure the bug was not
40
+ already reported** (use the search bar on GitHub under Issues).
41
+
42
+ Once you've confirmed the bug hasn't already been reported, please include the following information in your issue so we can quickly resolve it:
43
+
44
+ - Your **OS type and version** and **Browser type and version**.
45
+ - A short, self-contained, code snippet that allows us to reproduce the bug in
46
+ less than 30s.
47
+ - The _full_ traceback if an exception is raised.
48
+ - Attach any other additional information, like screenshots, you think may help.
49
+
50
+ To get the OS and software versions automatically, run the following command:
51
+
52
+ ```bash
53
+ npx envinfo --system --binaries --browsers
54
+ ```
55
+
56
+ ### Do you want a new feature?
57
+
58
+ If there is a new feature you'd like to see in 🤗 Playground, please open an issue and describe:
59
+
60
+ 1. What is the _motivation_ behind this feature? Is it related to a problem or frustration with the app? Is it something you worked on and think it could benefit the community?
61
+
62
+ Whatever it is, we'd love to hear about it!
63
+
64
+ 2. Describe your requested feature in as much detail as possible. The more you can tell us about it, the better we'll be able to help you.
65
+ 3. Provide a _code snippet_ that demonstrates the features usage.
66
+ 4. If the feature is related to a paper, please include a link.
67
+
68
+ If your issue is well written we're already 80% of the way there by the time you create it.
69
+
70
+ ## Create a Pull Request
71
+
72
+ Before writing any code, we strongly advise you to search through the existing PRs or
73
+ issues to make sure nobody is already working on the same thing. If you are
74
+ unsure, it is always a good idea to open an issue to get some feedback.
75
+
76
+ You will need basic `git` proficiency to contribute to
77
+ 🤗 Playground. While `git` is not the easiest tool to use, it has the greatest
78
+ manual. Type `git --help` in a shell and enjoy! If you prefer books, [Pro
79
+ Git](https://git-scm.com/book/en/v2) is a very good reference.
80
+
81
+ 1. Fork the [repository](https://github.com/huggingface/inference-playground) by
82
+ clicking on the **[Fork](https://github.com/huggingface/inference-playground/fork)** button on the repository's page. This creates a copy of the code
83
+ under your GitHub user account.
84
+
85
+ 2. Clone your fork to your local disk, and add the base repository as a remote:
86
+
87
+ ```bash
88
+ git clone [email protected]:<your Github handle>/inference-playground.git
89
+ cd inference-playground
90
+ git remote add upstream https://github.com/huggingface/inference-playground.git
91
+ ```
92
+
93
+ 3. Create a new branch to hold your development changes:
94
+
95
+ ```bash
96
+ git checkout -b a-descriptive-name-for-my-changes
97
+ ```
98
+
99
+ 🚨 **Do not** work on the `main` branch!
100
+
101
+ 4. Develop the features in your branch.
102
+
103
+ Once you're happy with your changes, add the changed files with `git add` and
104
+ record your changes locally with `git commit`:
105
+
106
+ ```bash
107
+ git add modified_file.svelte
108
+ git commit
109
+ ```
110
+
111
+ Please remember to write [good commit
112
+ messages](https://chris.beams.io/posts/git-commit/) to clearly communicate the changes you made!
113
+
114
+ To keep your copy of the code up to date with the original
115
+ repository, rebase your branch on `upstream/branch` _before_ you open a pull request or if requested by a maintainer:
116
+
117
+ ```bash
118
+ git fetch upstream
119
+ git rebase upstream/main
120
+ ```
121
+
122
+ Push your changes to your branch:
123
+
124
+ ```bash
125
+ git push -u origin a-descriptive-name-for-my-changes
126
+ ```
127
+
128
+ If you've already opened a pull request, you'll need to force push with the `--force` flag. Otherwise, if the pull request hasn't been opened yet, you can just push your changes normally.
129
+
130
+ 5. Now you can go to your fork of the repository on GitHub and click on **Pull Request** to open a pull request. Make sure you tick off all the boxes on our [checklist](#pull-request-checklist) below. When you're ready, you can send your changes to the project maintainers for review.
131
+
132
+ 6. It's ok if maintainers request changes, it happens to our core contributors
133
+ too! So everyone can see the changes in the pull request, work in your local
134
+ branch and push the changes to your fork. They will automatically appear in
135
+ the pull request.
136
+
137
+ ### Pull request checklist
138
+
139
+ ☐ The pull request title should summarize your contribution.<br>
140
+ ☐ If your pull request addresses an issue, please mention the issue number in the pull
141
+ request description to make sure they are linked (and people viewing the issue know you
142
+ are working on it).<br>
143
+ ☐ To indicate a work in progress please prefix the title with `[WIP]`. These are
144
+ useful to avoid duplicated work, and to differentiate it from PRs ready to be merged.<br>
145
+
146
+ ### Develop on Windows
147
+
148
+ On Windows (unless you're working in [Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl/) or WSL), you need to configure git to transform Windows `CRLF` line endings to Linux `LF` line endings:
149
+
150
+ ```bash
151
+ git config core.autocrlf input
152
+ ```
153
+
154
+ One way to run the `make` command on Windows is with MSYS2:
155
+
156
+ 1. [Download MSYS2](https://www.msys2.org/), and we assume it's installed in `C:\msys64`.
157
+ 2. Open the command line `C:\msys64\msys2.exe` (it should be available from the **Start** menu).
158
+ 3. Run in the shell: `pacman -Syu` and install `make` with `pacman -S make`.
159
+ 4. Add `C:\msys64\usr\bin` to your PATH environment variable.
160
+
161
+ You can now use `make` from any terminal (PowerShell, cmd.exe, etc.)! 🎉
162
+
163
+ ### Sync a forked repository with upstream main (the Hugging Face repository)
164
+
165
+ When updating the main branch of a forked repository, please follow these steps to avoid pinging the upstream repository which adds reference notes to each upstream PR, and sends unnecessary notifications to the developers involved in these PRs.
166
+
167
+ 1. When possible, avoid syncing with the upstream using a branch and PR on the forked repository. Instead, merge directly into the forked main.
168
+ 2. If a PR is absolutely necessary, use the following steps after checking out your branch:
169
+
170
+ ```bash
171
+ git checkout -b your-branch-for-syncing
172
+ git pull --squash --no-commit upstream main
173
+ git commit -m '<your message without GitHub references>'
174
+ git push --set-upstream origin your-branch-for-syncing
175
+ ```
README.md CHANGED
@@ -8,17 +8,70 @@ pinned: false
8
  app_port: 3000
9
  ---
10
 
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12
 
13
- Demo: https://huggingface.co/spaces/huggingface-projects/inference-playground
 
 
 
 
 
 
 
 
14
 
15
- ## Local development
 
 
 
 
16
 
17
- ```sh
18
- pnpm i
19
- HF_TOKEN=your_hf_token pnpm run dev
20
- ```
21
 
22
- get your READ token from http://hf.co/settings/token
23
 
24
- Hint: Use antfu's [ni](https://github.com/antfu-collective/ni) and never memorize a package manager again
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  app_port: 3000
9
  ---
10
 
11
+ # Inference Playground
12
 
13
+ <p align="center">
14
+ <picture>
15
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/huggingface/inference-playground/raw/main/banner-dark.svg">
16
+ <source media="(prefers-color-scheme: light)" srcset="https://github.com/huggingface/inference-playground/raw/main/banner-light.svg">
17
+ <img alt="Hugging Face Inference Playground" src="https://github.com/huggingface/inference-playground/raw/main/banner-light.svg" width="352" height="59" style="max-width: 100%;">
18
+ </picture>
19
+ <br/>
20
+ <br/>
21
+ </p>
22
 
23
+ <p align="center">
24
+ <a href="https://github.com/huggingface/inference-playground/actions/workflows/lint-and-test.yml"><img alt="Build" src="https://img.shields.io/github/actions/workflow/status/huggingface/inference-playground/lint-and-test.yml?style=flat"></a>
25
+ <a href="https://github.com/huggingface/inference-playground/blob/main/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/huggingface/inference-playground.svg?color=blue"></a>
26
+ <a href="https://github.com/huggingface/transformers/blob/main/CODE_OF_CONDUCT.md"><img alt="Contributor Covenant" src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg"></a>
27
+ </p>
28
 
29
+ This application provides a user interface to interact with various large language models, leveraging the `@huggingface/inference` library. It allows you to easily test and compare models hosted on Hugging Face, connect to different third-party Inference Providers, and even configure your own custom OpenAI-compatible endpoints.
 
 
 
30
 
31
+ ## Local Setup
32
 
33
+ TL;DR: After cloning, run `pnpm i && pnpm run dev --open`
34
+
35
+ ### Prerequisites
36
+
37
+ Before you begin, ensure you have the following installed:
38
+
39
+ - **Node.js:** Version 20 or later is recommended.
40
+ - **pnpm:** Install it globally via `npm install -g pnpm`.
41
+ - **Hugging Face Account & Token:** You'll need a free Hugging Face account and an access token to interact with models. Generate a token with at least `read` permissions from [hf.co/settings/tokens](https://huggingface.co/settings/tokens).
42
+
43
+ Follow these steps to get the Inference Playground running on your local machine:
44
+
45
+ 1. **Clone the Repository:**
46
+
47
+ ```bash
48
+ git clone https://github.com/huggingface/inference-playground.git
49
+ cd inference-playground
50
+ ```
51
+
52
+ 2. **Install Dependencies:**
53
+
54
+ ```bash
55
+ pnpm install
56
+ ```
57
+
58
+ 3. **Start the Development Server:**
59
+
60
+ ```bash
61
+ pnpm run dev
62
+ ```
63
+
64
+ 4. **Access the Playground:**
65
+ - Open your web browser and navigate to `http://localhost:5173` (or the port indicated in your terminal).
66
+
67
+ ## Features
68
+
69
+ - **Model Interaction:** Chat with a wide range of models available through Hugging Face Inference.
70
+ - **Provider Support:** Connect to various third-party inference providers (like Together, Fireworks, Replicate, etc.).
71
+ - **Custom Endpoints:** Add and use your own OpenAI-compatible API endpoints.
72
+ - **Comparison View:** Run prompts against two different models or configurations side-by-side.
73
+ - **Configuration:** Adjust generation parameters like temperature, max tokens, and top-p.
74
+ - **Session Management:** Save and load your conversation setups using Projects and Checkpoints.
75
+ - **Code Snippets:** Generate code snippets for various languages to replicate your inference calls.
76
+
77
+ We hope you find the Inference Playground useful for exploring and experimenting with language models!
src/routes/api/models/+server.ts CHANGED
@@ -128,8 +128,9 @@ export const GET: RequestHandler = async ({ fetch }) => {
128
  // Make the needed API calls in parallel
129
  const apiPromises: Promise<Response | void>[] = [];
130
  if (needTextGenFetch) {
 
131
  apiPromises.push(
132
- fetch(buildApiUrl({ ...queryParams, pipeline_tag: "text-generation" }), requestInit).then(async response => {
133
  if (!response.ok) {
134
  console.error(`Error fetching text-generation models`, response.status, response.statusText);
135
  newFailedApiCalls.textGeneration = true;
 
128
  // Make the needed API calls in parallel
129
  const apiPromises: Promise<Response | void>[] = [];
130
  if (needTextGenFetch) {
131
+ const url = buildApiUrl({ ...queryParams, pipeline_tag: "text-generation" });
132
  apiPromises.push(
133
+ fetch(url, requestInit).then(async response => {
134
  if (!response.ok) {
135
  console.error(`Error fetching text-generation models`, response.status, response.statusText);
136
  newFailedApiCalls.textGeneration = true;
static/banner-dark.svg ADDED
static/banner-light.svg ADDED