Spaces:
Sleeping
Sleeping
updated prompt
Browse files- app.py +16 -13
- chroma/28c81268-af8d-4e89-9744-aee894bcbde6/data_level0.bin +0 -3
- chroma/28c81268-af8d-4e89-9744-aee894bcbde6/header.bin +0 -3
- chroma/28c81268-af8d-4e89-9744-aee894bcbde6/index_metadata.pickle +0 -3
- chroma/28c81268-af8d-4e89-9744-aee894bcbde6/length.bin +0 -3
- chroma/28c81268-af8d-4e89-9744-aee894bcbde6/link_lists.bin +0 -3
- chroma/8b53584a-0ad0-4736-8a94-cfa8d70be50f/index_metadata.pickle +0 -3
- chroma/8b53584a-0ad0-4736-8a94-cfa8d70be50f/link_lists.bin +0 -3
- chroma/c2db2536-5ceb-4ce6-b43c-7b5a8994dc6a/data_level0.bin +0 -3
- chroma/c2db2536-5ceb-4ce6-b43c-7b5a8994dc6a/header.bin +0 -3
- chroma/c2db2536-5ceb-4ce6-b43c-7b5a8994dc6a/length.bin +0 -3
- chroma/chroma.sqlite3 +2 -2
- chroma/{8b53584a-0ad0-4736-8a94-cfa8d70be50f → db67d0e6-bc9f-4536-a3d5-3b23e19e0212}/data_level0.bin +1 -1
- chroma/{8b53584a-0ad0-4736-8a94-cfa8d70be50f → db67d0e6-bc9f-4536-a3d5-3b23e19e0212}/header.bin +0 -0
- chroma/{c2db2536-5ceb-4ce6-b43c-7b5a8994dc6a → db67d0e6-bc9f-4536-a3d5-3b23e19e0212}/index_metadata.pickle +1 -1
- chroma/{8b53584a-0ad0-4736-8a94-cfa8d70be50f → db67d0e6-bc9f-4536-a3d5-3b23e19e0212}/length.bin +1 -1
- chroma/{c2db2536-5ceb-4ce6-b43c-7b5a8994dc6a → db67d0e6-bc9f-4536-a3d5-3b23e19e0212}/link_lists.bin +1 -1
- gradio_cached_examples/10/log.csv +0 -5
- requirements.txt +2 -1
app.py
CHANGED
@@ -72,16 +72,20 @@ threshold = 0.6
|
|
72 |
def answer(input_text,context=None):
|
73 |
if context:
|
74 |
tips = "提示:\n"
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
81 |
else:
|
82 |
tips=""
|
83 |
|
84 |
-
prompt = f"{input_text}\n{tips}\n谜底是什么?"
|
85 |
prompt = prompt.strip()
|
86 |
|
87 |
print(f"===\n{prompt}")
|
@@ -120,7 +124,7 @@ def helper_rag(text):
|
|
120 |
context = []
|
121 |
for doc in docs_out:
|
122 |
if doc[1] > threshold:
|
123 |
-
context.append((
|
124 |
|
125 |
return context
|
126 |
|
@@ -132,7 +136,7 @@ def helper_text(text_input,radio=None):
|
|
132 |
text_input = chinese_converter.to_simplified(text_input)
|
133 |
chinese_type = "traditional"
|
134 |
|
135 |
-
text_input = re.sub(r'hint',"猜",text_input,flags=re.I)
|
136 |
|
137 |
#if not any(c in text_input for c in ["猜", "打"]):
|
138 |
# warning = "请给一个提示,提示格式,例子:猜一水果,打一字。"
|
@@ -140,10 +144,9 @@ def helper_text(text_input,radio=None):
|
|
140 |
# warning = chinese_converter.to_traditional(warning)
|
141 |
# return warning
|
142 |
|
143 |
-
text=f"""猜谜语:\n谜面:{text_input}
|
144 |
-
"""
|
145 |
|
146 |
-
context = helper_rag(
|
147 |
|
148 |
output = answer(text,context=context)
|
149 |
|
@@ -267,7 +270,7 @@ with gr.Blocks() as demo:
|
|
267 |
["小家伙穿黄袍,花丛中把房造。飞到西来飞到东,人人夸他爱劳动。(猜一动物)"],
|
268 |
["一物生来身穿三百多件衣,每天脱一件,年底剩张皮。(猜一物品)"],
|
269 |
["A thousand threads, a million strands. Reaching the water, vanishing all at once. (Hint: natural phenomenon)"],
|
270 |
-
["
|
271 |
]
|
272 |
radio = gr.Radio(
|
273 |
["简体中文","繁體中文", "English"],show_label=False,value="简体中文"
|
|
|
72 |
def answer(input_text,context=None):
|
73 |
if context:
|
74 |
tips = "提示:\n"
|
75 |
+
for i, tip in enumerate(context):
|
76 |
+
#if i==0:
|
77 |
+
# tips +="最佳答案\n"
|
78 |
+
#else:
|
79 |
+
# tips +="較差答案\n"
|
80 |
+
tips += f"谜面:{tip[0]} 谜底是:{tip[1]} "
|
81 |
+
tips +="\n"
|
82 |
+
print (f"====\n{input_text}\n{context[0][0]} 谜底是:{context[0][1]} {context[0][2]}")
|
83 |
+
if context[0][2] >=0.9:
|
84 |
+
return f"谜底是:{context[0][1]}"
|
85 |
else:
|
86 |
tips=""
|
87 |
|
88 |
+
prompt = f"{input_text}\n\n{tips}\n\n谜底是什么?"
|
89 |
prompt = prompt.strip()
|
90 |
|
91 |
print(f"===\n{prompt}")
|
|
|
124 |
context = []
|
125 |
for doc in docs_out:
|
126 |
if doc[1] > threshold:
|
127 |
+
context.append((doc[0].page_content, doc[0].metadata['answer'], doc[1]))
|
128 |
|
129 |
return context
|
130 |
|
|
|
136 |
text_input = chinese_converter.to_simplified(text_input)
|
137 |
chinese_type = "traditional"
|
138 |
|
139 |
+
text_input = re.sub(r'hint:',"猜",text_input,flags=re.I)
|
140 |
|
141 |
#if not any(c in text_input for c in ["猜", "打"]):
|
142 |
# warning = "请给一个提示,提示格式,例子:猜一水果,打一字。"
|
|
|
144 |
# warning = chinese_converter.to_traditional(warning)
|
145 |
# return warning
|
146 |
|
147 |
+
text=f"""猜谜语:\n谜面:{text_input}"""
|
|
|
148 |
|
149 |
+
context = helper_rag(text_input)
|
150 |
|
151 |
output = answer(text,context=context)
|
152 |
|
|
|
270 |
["小家伙穿黄袍,花丛中把房造。飞到西来飞到东,人人夸他爱劳动。(猜一动物)"],
|
271 |
["一物生来身穿三百多件衣,每天脱一件,年底剩张皮。(猜一物品)"],
|
272 |
["A thousand threads, a million strands. Reaching the water, vanishing all at once. (Hint: natural phenomenon)"],
|
273 |
+
["无底洞(猜一成语)"],
|
274 |
]
|
275 |
radio = gr.Radio(
|
276 |
["简体中文","繁體中文", "English"],show_label=False,value="简体中文"
|
chroma/28c81268-af8d-4e89-9744-aee894bcbde6/data_level0.bin
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:0067068c3258f065668e2ad17382df3424f1c001807139881c2dc1691772ac7b
|
3 |
-
size 28908000
|
|
|
|
|
|
|
|
chroma/28c81268-af8d-4e89-9744-aee894bcbde6/header.bin
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:4b630aa796b842f9cb3af4a5f7cbc9fd3fc793047cec78a183ac3eaa83d68497
|
3 |
-
size 100
|
|
|
|
|
|
|
|
chroma/28c81268-af8d-4e89-9744-aee894bcbde6/index_metadata.pickle
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:e1f937c780ce5ab483dc40c3bf8d8408b3fa3d1bf03b5d20488b0d5b8a906fde
|
3 |
-
size 520085
|
|
|
|
|
|
|
|
chroma/28c81268-af8d-4e89-9744-aee894bcbde6/length.bin
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:3a76c43e6fc007afd7f87d90b5a60a482449450491f8b307c5617b83471cf7a7
|
3 |
-
size 36000
|
|
|
|
|
|
|
|
chroma/28c81268-af8d-4e89-9744-aee894bcbde6/link_lists.bin
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:dcde28a793504ace57c738a180d964a0c8ed59bf30194cdde6f16484f267ba06
|
3 |
-
size 80540
|
|
|
|
|
|
|
|
chroma/8b53584a-0ad0-4736-8a94-cfa8d70be50f/index_metadata.pickle
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:82f3e6de81589372542997842764e185b0aed0bce415b471bae9905ec01e9721
|
3 |
-
size 55974
|
|
|
|
|
|
|
|
chroma/8b53584a-0ad0-4736-8a94-cfa8d70be50f/link_lists.bin
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:275efc4c1e990a422ddd8947ffa1013a9d55fa3f021c5b96c06835b708db448e
|
3 |
-
size 8148
|
|
|
|
|
|
|
|
chroma/c2db2536-5ceb-4ce6-b43c-7b5a8994dc6a/data_level0.bin
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:0fab3b1442c2e9319c9406cb2db197e9b806a2d4122f8c3575c62d4a0fff1dc5
|
3 |
-
size 3212000
|
|
|
|
|
|
|
|
chroma/c2db2536-5ceb-4ce6-b43c-7b5a8994dc6a/header.bin
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:61f185c42c6b3379360fa19d3ff03ef53f86c938371ab55230c04b3aa051c549
|
3 |
-
size 100
|
|
|
|
|
|
|
|
chroma/c2db2536-5ceb-4ce6-b43c-7b5a8994dc6a/length.bin
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:9814e6d812bbb532273fec5061e2a38f55f8cab0dbe292ff0ba8d230076943ce
|
3 |
-
size 4000
|
|
|
|
|
|
|
|
chroma/chroma.sqlite3
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5b44b6dd7c8ba23f9faa645c2562ec8b601e93f915588d07876518ac0a686614
|
3 |
+
size 7327744
|
chroma/{8b53584a-0ad0-4736-8a94-cfa8d70be50f → db67d0e6-bc9f-4536-a3d5-3b23e19e0212}/data_level0.bin
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 3212000
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b6b26a194dc2620543256c04ccea396ecd8de5787096f7d87d9a9474e9480754
|
3 |
size 3212000
|
chroma/{8b53584a-0ad0-4736-8a94-cfa8d70be50f → db67d0e6-bc9f-4536-a3d5-3b23e19e0212}/header.bin
RENAMED
File without changes
|
chroma/{c2db2536-5ceb-4ce6-b43c-7b5a8994dc6a → db67d0e6-bc9f-4536-a3d5-3b23e19e0212}/index_metadata.pickle
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 55974
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:84ebb46c8fd7958ede9a01c261de4f9f85f1020cf32b8ef2afeca67e0b0c62d0
|
3 |
size 55974
|
chroma/{8b53584a-0ad0-4736-8a94-cfa8d70be50f → db67d0e6-bc9f-4536-a3d5-3b23e19e0212}/length.bin
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 4000
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:45569e91b592cc6a9fce4ee6a878eb041638b21d09934f0b7158eda3aa83ad89
|
3 |
size 4000
|
chroma/{c2db2536-5ceb-4ce6-b43c-7b5a8994dc6a → db67d0e6-bc9f-4536-a3d5-3b23e19e0212}/link_lists.bin
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 8148
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:421b1cc5ed6bbb1c3f7433d3afd18fcc96e7b0b4d670b4f374b599eec28bd8f2
|
3 |
size 8148
|
gradio_cached_examples/10/log.csv
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
谜底,flag,username,timestamp
|
2 |
-
谜底是:蜜蜂,,,2024-02-22 22:14:00.108103
|
3 |
-
谜底是:日历,,,2024-02-22 22:14:01.397728
|
4 |
-
谜底是:雨,,,2024-02-22 22:14:02.151370
|
5 |
-
谜底是:深不可测,,,2024-02-22 22:14:02.200411
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -5,4 +5,5 @@ chromadb
|
|
5 |
sentence-transformers
|
6 |
sentencepiece
|
7 |
hanzidentifier
|
8 |
-
chinese-converter
|
|
|
|
5 |
sentence-transformers
|
6 |
sentencepiece
|
7 |
hanzidentifier
|
8 |
+
chinese-converter
|
9 |
+
gradio
|