CISCai commited on
Commit
0f1d531
·
verified ·
1 Parent(s): 11e4190

Expose permalink if possible

Browse files
Files changed (1) hide show
  1. app.py +32 -9
app.py CHANGED
@@ -180,6 +180,11 @@ with gr.Blocks(
180
  visible = False,
181
  )
182
 
 
 
 
 
 
183
  btn_download = gr.Button(
184
  "Download GGUF",
185
  variant = "primary",
@@ -546,6 +551,7 @@ Any framework based on `llama-cpp-python` will let you select which chat templat
546
  meta_changes,
547
  file_meta,
548
  meta_keys,
 
549
  btn_download,
550
  ]
551
  state_change_components = [
@@ -633,6 +639,9 @@ Any framework based on `llama-cpp-python` will let you select which chat templat
633
  meta_keys: gr.Dropdown(
634
  visible = False,
635
  ),
 
 
 
636
  btn_download: gr.Button(
637
  visible = False,
638
  ),
@@ -686,6 +695,9 @@ Any framework based on `llama-cpp-python` will let you select which chat templat
686
  None,
687
  visible = False,
688
  ),
 
 
 
689
  btn_download: gr.Button(
690
  visible = False,
691
  ),
@@ -765,6 +777,9 @@ Any framework based on `llama-cpp-python` will let you select which chat templat
765
  None,
766
  visible = False,
767
  ),
 
 
 
768
  btn_download: gr.Button(
769
  visible = False,
770
  ),
@@ -1037,15 +1052,19 @@ Any framework based on `llama-cpp-python` will let you select which chat templat
1037
  if link.startswith('http:'):
1038
  link = 'https' + link[4:]
1039
 
1040
- # if meta.rem or meta.add:
1041
- # link += '&' + urlencode(
1042
- # {
1043
- # 'rem': meta.rem,
1044
- # 'add': [json.dumps([k, *v], ensure_ascii = False, separators = (',', ':')) for k, v in meta.add.items()],
1045
- # },
1046
- # doseq = True,
1047
- # safe = '[]{}:"\',',
1048
- # )
 
 
 
 
1049
 
1050
  return {
1051
  meta_state: meta,
@@ -1060,6 +1079,10 @@ Any framework based on `llama-cpp-python` will let you select which chat templat
1060
  sorted(meta.key.keys() | standard_metadata.keys()),
1061
  value = '',
1062
  ),
 
 
 
 
1063
  btn_download: gr.Button(
1064
  link = link,
1065
  visible = True if changes else False,
 
180
  visible = False,
181
  )
182
 
183
+ meta_permalink = gr.Markdown(
184
+ None,
185
+ visible = False,
186
+ )
187
+
188
  btn_download = gr.Button(
189
  "Download GGUF",
190
  variant = "primary",
 
551
  meta_changes,
552
  file_meta,
553
  meta_keys,
554
+ meta_permalink,
555
  btn_download,
556
  ]
557
  state_change_components = [
 
639
  meta_keys: gr.Dropdown(
640
  visible = False,
641
  ),
642
+ meta_permalink: gr.Markdown(
643
+ visible = False,
644
+ ),
645
  btn_download: gr.Button(
646
  visible = False,
647
  ),
 
695
  None,
696
  visible = False,
697
  ),
698
+ meta_permalink: gr.Markdown(
699
+ visible = False,
700
+ ),
701
  btn_download: gr.Button(
702
  visible = False,
703
  ),
 
777
  None,
778
  visible = False,
779
  ),
780
+ meta_permalink: gr.Markdown(
781
+ visible = False,
782
+ ),
783
  btn_download: gr.Button(
784
  visible = False,
785
  ),
 
1052
  if link.startswith('http:'):
1053
  link = 'https' + link[4:]
1054
 
1055
+ permalink = None
1056
+ if meta.rem or meta.add:
1057
+ permalink = link.split("&")[0] + '&' + urlencode(
1058
+ {
1059
+ 'rem': meta.rem,
1060
+ 'add': [json.dumps([k, *v], ensure_ascii = False, separators = (',', ':')) for k, v in meta.add.items()],
1061
+ },
1062
+ doseq = True,
1063
+ safe = '[]{}:"\',',
1064
+ )
1065
+
1066
+ if len(permalink) > 8192:
1067
+ permalink = None
1068
 
1069
  return {
1070
  meta_state: meta,
 
1079
  sorted(meta.key.keys() | standard_metadata.keys()),
1080
  value = '',
1081
  ),
1082
+ meta_permalink: gr.Markdown(
1083
+ f"Copy this [permalink]({permalink}) to the modified GGUF if you need to share changes.",
1084
+ visible = True if permalink else False,
1085
+ ),
1086
  btn_download: gr.Button(
1087
  link = link,
1088
  visible = True if changes else False,