Spaces:
Sleeping
Sleeping
Petzys
commited on
Commit
·
180e924
1
Parent(s):
606e93c
feat: added new theme
Browse files
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
|
|
|
| 1 |
---
|
| 2 |
+
title: xkcd Finder
|
| 3 |
+
emoji: 🦙
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
app.py
CHANGED
|
@@ -20,11 +20,10 @@ def build_index():
|
|
| 20 |
model = SentenceTransformer("all-MiniLM-L6-v2")
|
| 21 |
texts = []
|
| 22 |
for ex in ds:
|
| 23 |
-
id_ = str(ex["id"]) if ex["id"] else ""
|
| 24 |
title = ex["title"] if ex["title"] else ""
|
| 25 |
transcript = ex["transcript"] if ex["transcript"] else ""
|
| 26 |
explanation = ex["explanation"] if "explanation" in ex and ex["explanation"] else ""
|
| 27 |
-
texts.append(f"{
|
| 28 |
|
| 29 |
embeddings = model.encode(texts, convert_to_numpy=True, show_progress_bar=True)
|
| 30 |
dim = embeddings.shape[1]
|
|
@@ -93,7 +92,7 @@ Please answer with the comic ID, URL (https://xkcd.com/ID/) and a short explanat
|
|
| 93 |
{"role": "user", "content": prompt},
|
| 94 |
],
|
| 95 |
max_tokens=200,
|
| 96 |
-
temperature=0.0,
|
| 97 |
)
|
| 98 |
|
| 99 |
# Be tolerant to slight schema differences
|
|
@@ -127,6 +126,8 @@ with gr.Blocks() as demo:
|
|
| 127 |
"A comic for programmers debugging code.",
|
| 128 |
"Life advice in comic form.",
|
| 129 |
],
|
|
|
|
|
|
|
| 130 |
)
|
| 131 |
|
| 132 |
if __name__ == "__main__":
|
|
|
|
| 20 |
model = SentenceTransformer("all-MiniLM-L6-v2")
|
| 21 |
texts = []
|
| 22 |
for ex in ds:
|
|
|
|
| 23 |
title = ex["title"] if ex["title"] else ""
|
| 24 |
transcript = ex["transcript"] if ex["transcript"] else ""
|
| 25 |
explanation = ex["explanation"] if "explanation" in ex and ex["explanation"] else ""
|
| 26 |
+
texts.append(f"{title} {transcript} {explanation}")
|
| 27 |
|
| 28 |
embeddings = model.encode(texts, convert_to_numpy=True, show_progress_bar=True)
|
| 29 |
dim = embeddings.shape[1]
|
|
|
|
| 92 |
{"role": "user", "content": prompt},
|
| 93 |
],
|
| 94 |
max_tokens=200,
|
| 95 |
+
temperature=0.0, # TODO
|
| 96 |
)
|
| 97 |
|
| 98 |
# Be tolerant to slight schema differences
|
|
|
|
| 126 |
"A comic for programmers debugging code.",
|
| 127 |
"Life advice in comic form.",
|
| 128 |
],
|
| 129 |
+
type="messages",
|
| 130 |
+
theme='gstaff/xkcd',
|
| 131 |
)
|
| 132 |
|
| 133 |
if __name__ == "__main__":
|