Skip to content

Commit

Permalink
Merge branch 'main' into enable-streaming-in-client
Browse files Browse the repository at this point in the history
  • Loading branch information
abidlabs committed Aug 21, 2023
2 parents 0337b8f + 502f101 commit cc1f16c
Show file tree
Hide file tree
Showing 168 changed files with 2,929 additions and 3,155 deletions.
7 changes: 7 additions & 0 deletions .changeset/afraid-jeans-shine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@gradio/dataframe": minor
"@gradio/markdown": minor
"gradio": minor
---

feat:Move markdown & latex processing to the frontend for the gr.Markdown and gr.DataFrame components
53 changes: 35 additions & 18 deletions .changeset/changeset.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const { packages, rootDir } = getPackagesSync(process.cwd());

/**
*
* @param {string} package_name
* @returns {string[]}
* @param {string} package_name The name of the package to find the directories for
* @returns {string[]} The directories for the package
*/
function find_packages_dirs(package_name) {
/** @type {string[]} */
Expand All @@ -37,10 +37,10 @@ function find_packages_dirs(package_name) {
const changelogFunctions = {
/**
*
* @param {Changeset[]} changesets
* @param {any} dependenciesUpdated
* @param {any} options
* @returns
* @param {Changeset[]} changesets The changesets that have been created
* @param {any} dependenciesUpdated The dependencies that have been updated
* @param {any} options The options passed to the changelog generator
* @returns {Promise<string>} The release line for the dependencies
*/
getDependencyReleaseLine: async (
changesets,
Expand Down Expand Up @@ -73,8 +73,8 @@ const changelogFunctions = {
const updatedDepenenciesList = dependenciesUpdated.map(
/**
*
* @param {any} dependency
* @returns
* @param {any} dependency The dependency that has been updated
* @returns {string} The formatted dependency
*/
(dependency) => ` - ${dependency.name}@${dependency.newVersion}`
);
Expand All @@ -83,10 +83,10 @@ const changelogFunctions = {
},
/**
*
* @param {{summary: string, id: string, commit: string, releases: {name: string}[]}} changeset
* @param {any} type
* @param {any} options
* @returns
* @param {{summary: string, id: string, commit: string, releases: {name: string}[]}} changeset The changeset that has been created
* @param {any} type The type of changeset
* @param {any} options The options passed to the changelog generator
* @returns {Promise<string>} The release line for the changeset
*/
getReleaseLine: async (changeset, type, options) => {
if (!options || !options.repo) {
Expand Down Expand Up @@ -190,9 +190,8 @@ const changelogFunctions = {

if (lines._handled.includes(changeset.id)) {
return "done";
} else {
lines._handled.push(changeset.id);
}
lines._handled.push(changeset.id);

changeset.releases.forEach((release) => {
if (!lines[release.name])
Expand Down Expand Up @@ -237,10 +236,7 @@ const changelogFunctions = {

formatted_summary = `${_heading}\n${_rest.join("\n")}`;
} else {
formatted_summary = `${prefix ? `${prefix} -` : ""} ${summary.replace(
/[\s\.]$/,
""
)}.${suffix}`;
formatted_summary = handle_line(summary, prefix, suffix);
}

//@ts-ignore
Expand All @@ -260,4 +256,25 @@ const changelogFunctions = {
}
};

/**
* @param {string} str The changelog entry
* @param {string} prefix The prefix to add to the first line
* @param {string} suffix The suffix to add to the last line
* @returns {string} The formatted changelog entry
*/
function handle_line(str, prefix, suffix) {
const [_s, ...lines] = str.split("\n").filter(Boolean);

const desc = `${prefix ? `${prefix} -` : ""} ${_s.replace(
/[\s\.]$/,
""
)}. ${suffix}`;

if (_s.length === 1) {
return desc;
}

return [desc, ...lines.map((l) => ` ${l}`)].join("/n");
}

module.exports = changelogFunctions;
6 changes: 6 additions & 0 deletions .changeset/curly-hands-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/file": minor
"gradio": minor
---

fix:Ensure File component uploads files to the server.
6 changes: 6 additions & 0 deletions .changeset/fast-eyes-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/chatbot": minor
"gradio": minor
---

feat:chore(deps): update dependency marked to v7
4 changes: 2 additions & 2 deletions .changeset/fix_changelogs.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ for (const pkg_name in packages) {
.map(([lines, title]) => {
if (title === "### Highlights") {
return `${title}\n\n${lines.join("\n\n")}`;
} else {
return `${title}\n\n${lines.join("\n")}`;
}

return `${title}\n\n${lines.join("\n")}`;
})
.join("\n\n");

Expand Down
5 changes: 5 additions & 0 deletions .changeset/hip-queens-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": minor
---

feat:Stop passing inputs and preprocessing on iterators
6 changes: 6 additions & 0 deletions .changeset/khaki-otters-wear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/dataframe": patch
"gradio": patch
---

fix:Better handling of empty dataframe in `gr.DataFrame`
5 changes: 5 additions & 0 deletions .changeset/lemon-memes-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": patch
---

fix:Fix `.update()` for `gr.Radio()` and `gr.CheckboxGroup()`
6 changes: 6 additions & 0 deletions .changeset/lovely-bikes-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/file": minor
"gradio": minor
---

feat:Allows setting a height to `gr.File` and improves the UI of the component
6 changes: 6 additions & 0 deletions .changeset/pink-rockets-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/file": patch
"gradio": patch
---

feat:Removes scrollbar from File preview when not needed
27 changes: 27 additions & 0 deletions .changeset/seven-cobras-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
"@gradio/annotatedimage": minor
"@gradio/app": minor
"@gradio/atoms": minor
"@gradio/audio": minor
"@gradio/checkbox": minor
"@gradio/checkboxgroup": minor
"@gradio/code": minor
"@gradio/colorpicker": minor
"@gradio/dataframe": minor
"@gradio/dropdown": minor
"@gradio/file": minor
"@gradio/gallery": minor
"@gradio/highlightedtext": minor
"@gradio/image": minor
"@gradio/label": minor
"@gradio/model3d": minor
"@gradio/number": minor
"@gradio/plot": minor
"@gradio/radio": minor
"@gradio/slider": minor
"@gradio/statustracker": minor
"@gradio/upload": minor
"gradio": minor
---

feat:Update i18n tokens and locale files
8 changes: 8 additions & 0 deletions .changeset/smart-comics-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@gradio/app": minor
"@gradio/audio": minor
"@gradio/file": minor
"gradio": minor
---

feat:ensure translations for audio work correctly
6 changes: 6 additions & 0 deletions .changeset/young-plums-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/app": patch
"gradio": patch
---

fix:Ensure `Blocks` translation copy renders correctly
3 changes: 2 additions & 1 deletion .config/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
**/.vscode/**
sweep.yaml
**/.vercel/**
**/build/**
**/build/**
**/*.md
27 changes: 14 additions & 13 deletions gradio/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,23 +1080,21 @@ async def call_function(
block_fn = self.fns[fn_index]
assert block_fn.fn, f"function with index {fn_index} not defined."
is_generating = False

if block_fn.inputs_as_dict:
processed_input = [dict(zip(block_fn.inputs, processed_input))]

request = requests[0] if isinstance(requests, list) else requests
processed_input, progress_index, _ = special_args(
block_fn.fn, processed_input, request, event_data
)
progress_tracker = (
processed_input[progress_index] if progress_index is not None else None
)

start = time.time()

fn = utils.get_function_with_locals(block_fn.fn, self, event_id)

if iterator is None: # If not a generator function that has already run
if block_fn.inputs_as_dict:
processed_input = [dict(zip(block_fn.inputs, processed_input))]

processed_input, progress_index, _ = special_args(
block_fn.fn, processed_input, request, event_data
)
progress_tracker = (
processed_input[progress_index] if progress_index is not None else None
)

if progress_tracker is not None and progress_index is not None:
progress_tracker, fn = create_tracker(
self, event_id, fn, progress_tracker.track_tqdm
Expand Down Expand Up @@ -1425,8 +1423,11 @@ async def process_api(
data = list(zip(*data))
is_generating, iterator = None, None
else:
inputs = self.preprocess_data(fn_index, inputs, state)
old_iterator = iterators.get(fn_index, None) if iterators else None
if old_iterator:
inputs = []
else:
inputs = self.preprocess_data(fn_index, inputs, state)
was_generating = old_iterator is not None
result = await self.call_function(
fn_index, inputs, old_iterator, request, event_id, event_data
Expand Down
2 changes: 2 additions & 0 deletions gradio/components/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def update(
visible: bool | None = None,
height: int | None = None,
rtl: bool | None = None,
latex_delimiters: list[dict[str, str | bool]] | None = None,
show_share_button: bool | None = None,
show_copy_button: bool | None = None,
):
Expand All @@ -149,6 +150,7 @@ def update(
"height": height,
"show_share_button": show_share_button,
"rtl": rtl,
"latex_delimiters": latex_delimiters,
"show_copy_button": show_copy_button,
"__type__": "update",
}
Expand Down
5 changes: 5 additions & 0 deletions gradio/components/checkboxgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ def update(
interactive: bool | None = None,
visible: bool | None = None,
):
choices = (
None
if choices is None
else [c if isinstance(c, tuple) else (str(c), c) for c in choices]
)
return {
"choices": choices,
"label": label,
Expand Down

0 comments on commit cc1f16c

Please sign in to comment.