Spaces:
Runtime error
Runtime error
Merge remote-tracking branch 'gh-origin/hf'
Browse files- README.md +30 -6
- README_zh.md +30 -10
- app.py +5 -2
- llmriddles/llms/__init__.py +1 -0
- llmriddles/llms/chatglm.py +26 -0
- llmriddles/questions/level4.py +4 -4
- llmriddles/questions/level5.py +5 -1
- requirements-dev.txt +11 -0
- requirements.txt +1 -2
README.md
CHANGED
@@ -28,12 +28,26 @@ Welcome to LLM Riddles! This is a game of wits and courage with language models.
|
|
28 |
|
29 |
## :space_invader: How to Play
|
30 |
We provide an online version for players to directly access and try out.
|
31 |
-
- [ChatGPT + English(w/o key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTEN)
|
32 |
-
- [ChatGPT + Chinese(w/o key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTCN)
|
33 |
-
- [
|
34 |
-
- [ChatGPT + Chinese(w/ key)](
|
|
|
|
|
|
|
|
|
35 |
|
36 |
Local deployment can be done in the following ways:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
### ChatGPT + Chinese
|
38 |
```shell
|
39 |
QUESTION_LANG=cn QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3 -u app.py
|
@@ -42,6 +56,14 @@ QUESTION_LANG=cn QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3
|
|
42 |
```shell
|
43 |
QUESTION_LANG=en QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3 -u app.py
|
44 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
### Mistral-7B-Instruct-v0.1 + English
|
46 |
```shell
|
47 |
QUESTION_LANG=en QUESTION_LLM='mistral-7b' python3 -u app.py
|
@@ -56,7 +78,7 @@ The question format should include the following points:
|
|
56 |
- Pull Request title, example: feature(username): Chapter X-Level Design
|
57 |
- The ID you want to be mentioned
|
58 |
- Modify the corresponding chapter question files
|
59 |
-
- Modification of
|
60 |
|
61 |
For a complete example, please refer to: [Submit your own level design](https://github.com/opendilab/LLMRiddles/pull/6)
|
62 |
|
@@ -66,10 +88,11 @@ For a complete example, please refer to: [Submit your own level design](https://
|
|
66 |
- [x] Online trial link
|
67 |
- [x] Hugging Face Space link
|
68 |
- [x] Support Mistral-7B(English version)
|
69 |
-
- [
|
70 |
- [ ] Support Baichuan2-7B(Chinese version)
|
71 |
- [ ] Support LLaMA2-7B(English version)
|
72 |
- [ ] LLM inference speed optimization
|
|
|
73 |
|
74 |
## :speech_balloon: Feedback and Contribution
|
75 |
- [Start an Issue](https://github.com/opendilab/CodeMorpheus/issues/new/choose) on GitHub
|
@@ -80,6 +103,7 @@ For a complete example, please refer to: [Submit your own level design](https://
|
|
80 |
## :star2: Special Thanks
|
81 |
- Thanks to [Haoqiang Fan](https://www.zhihu.com/people/haoqiang-fan) for his original idea and title, which provided inspiration and motivation for the development and expansion of this project.
|
82 |
- Thanks to [HuggingFace](https://huggingface.co) for supporting and assisting the game.
|
|
|
83 |
- Thanks to [LLM Riddles contributors](https://github.com/opendilab/LLMRiddles/graphs/contributors) for their implementation and support.
|
84 |
|
85 |
## :label: License
|
|
|
28 |
|
29 |
## :space_invader: How to Play
|
30 |
We provide an online version for players to directly access and try out.
|
31 |
+
- [Hugging Face][ChatGPT + English(w/o key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTEN)
|
32 |
+
- [Hugging Face][ChatGPT + Chinese(w/o key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTCN)
|
33 |
+
- [Hugging Face][ChatGLM + Chinese(w/ key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGLMCN)
|
34 |
+
- [OpenXLab][ChatGPT + Chinese(w/o key)](https://openxlab.org.cn/apps/detail/OpenDILab/LLMRiddlesChatGPTCN)
|
35 |
+
- [OpenXLab][ChatGLM + Chinese(w/ key)](https://openxlab.org.cn/apps/detail/OpenDILab/LLMRiddlesChatGLMCN)
|
36 |
+
- [OpenXLab][ChatGLM + English(w/ key)](https://openxlab.org.cn/apps/detail/OpenDILab/LLMRiddlesChatGLMEN)
|
37 |
+
- [Private Server][Mistral + English(w/ key)](https://d9b451a97791dd8ef3.gradio.live)
|
38 |
+
- [Private Server][ChatGPT + Chinese(w/ key)](http://llmriddles.opendilab.net/)
|
39 |
|
40 |
Local deployment can be done in the following ways:
|
41 |
+
## Installation
|
42 |
+
### Use ChatGPT / ChatGLM API
|
43 |
+
```shell
|
44 |
+
pip3 install -r requirements.txt
|
45 |
+
```
|
46 |
+
### Deploy Mistral-7B-Instruct-v0.1 for local inference
|
47 |
+
```shell
|
48 |
+
pip3 install -r requirements-dev.txt
|
49 |
+
```
|
50 |
+
## Launch
|
51 |
### ChatGPT + Chinese
|
52 |
```shell
|
53 |
QUESTION_LANG=cn QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3 -u app.py
|
|
|
56 |
```shell
|
57 |
QUESTION_LANG=en QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3 -u app.py
|
58 |
```
|
59 |
+
### ChatGLM + Chinese
|
60 |
+
```shell
|
61 |
+
QUESTION_LANG=cn QUESTION_LLM='chatglm' QUESTION_LLM_KEY=<your API key> python3 -u app.py
|
62 |
+
```
|
63 |
+
### ChatGLM + English
|
64 |
+
```shell
|
65 |
+
QUESTION_LANG=en QUESTION_LLM='chatglm' QUESTION_LLM_KEY=<your API key> python3 -u app.py
|
66 |
+
```
|
67 |
### Mistral-7B-Instruct-v0.1 + English
|
68 |
```shell
|
69 |
QUESTION_LANG=en QUESTION_LLM='mistral-7b' python3 -u app.py
|
|
|
78 |
- Pull Request title, example: feature(username): Chapter X-Level Design
|
79 |
- The ID you want to be mentioned
|
80 |
- Modify the corresponding chapter question files
|
81 |
+
- Modification of \__init__.py
|
82 |
|
83 |
For a complete example, please refer to: [Submit your own level design](https://github.com/opendilab/LLMRiddles/pull/6)
|
84 |
|
|
|
88 |
- [x] Online trial link
|
89 |
- [x] Hugging Face Space link
|
90 |
- [x] Support Mistral-7B(English version)
|
91 |
+
- [x] Support ChatGLM(Chinese and English version)
|
92 |
- [ ] Support Baichuan2-7B(Chinese version)
|
93 |
- [ ] Support LLaMA2-7B(English version)
|
94 |
- [ ] LLM inference speed optimization
|
95 |
+
- [ ] More question levels and solution blogs
|
96 |
|
97 |
## :speech_balloon: Feedback and Contribution
|
98 |
- [Start an Issue](https://github.com/opendilab/CodeMorpheus/issues/new/choose) on GitHub
|
|
|
103 |
## :star2: Special Thanks
|
104 |
- Thanks to [Haoqiang Fan](https://www.zhihu.com/people/haoqiang-fan) for his original idea and title, which provided inspiration and motivation for the development and expansion of this project.
|
105 |
- Thanks to [HuggingFace](https://huggingface.co) for supporting and assisting the game.
|
106 |
+
- Thanks to [ChatGLM](https://chatglm.cn) for supporting and assisting the game, especially sufficient inference token support.
|
107 |
- Thanks to [LLM Riddles contributors](https://github.com/opendilab/LLMRiddles/graphs/contributors) for their implementation and support.
|
108 |
|
109 |
## :label: License
|
README_zh.md
CHANGED
@@ -15,12 +15,26 @@
|
|
15 |
|
16 |
## :space_invader: 如何试玩
|
17 |
我们提供了在线版本以供玩家直接访问试玩:
|
18 |
-
- [ChatGPT + 英文(需配置api key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTEN)
|
19 |
-
- [ChatGPT + 中文(需配置api key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTCN)
|
20 |
-
- [
|
21 |
-
- [ChatGPT + 中文(
|
|
|
|
|
|
|
|
|
22 |
|
23 |
本地部署可以通过以下方式:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
### ChatGPT + 中文
|
25 |
```shell
|
26 |
QUESTION_LANG=cn QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3 -u app.py
|
@@ -29,13 +43,17 @@ QUESTION_LANG=cn QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3
|
|
29 |
```shell
|
30 |
QUESTION_LANG=en QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3 -u app.py
|
31 |
```
|
32 |
-
###
|
|
|
|
|
|
|
|
|
33 |
```shell
|
34 |
-
QUESTION_LANG=
|
35 |
```
|
36 |
-
###
|
37 |
```shell
|
38 |
-
QUESTION_LANG=en QUESTION_LLM='
|
39 |
```
|
40 |
## :technologist: 为什么制作这个游戏
|
41 |
|
@@ -48,7 +66,7 @@ QUESTION_LANG=en QUESTION_LLM='llama2-7b' python3 -u app.py
|
|
48 |
- Pull Request标题,示例:feature(username): 章节X-关卡设计
|
49 |
- 希望被提及的ID
|
50 |
- 对应章节问题文件的修改
|
51 |
-
-
|
52 |
|
53 |
完整示例请参考:[提交属于自己的关卡设计](https://github.com/opendilab/LLMRiddles/pull/6)
|
54 |
|
@@ -58,10 +76,11 @@ QUESTION_LANG=en QUESTION_LLM='llama2-7b' python3 -u app.py
|
|
58 |
- [x] 在线试玩链接
|
59 |
- [x] Hugging Face Space 链接
|
60 |
- [x] 支持Mistral-7B(英文)
|
61 |
-
- [
|
62 |
- [ ] 支持Baichuan2-7B(中文)
|
63 |
- [ ] 支持LLaMA2-7B(英文)
|
64 |
- [ ] LLM 推理速度优化
|
|
|
65 |
|
66 |
## :speech_balloon: 反馈问题 & 提出建议
|
67 |
- 在 GitHub 上[发起 Issue](https://github.com/opendilab/CodeMorpheus/issues/new/choose)
|
@@ -72,6 +91,7 @@ QUESTION_LANG=en QUESTION_LLM='llama2-7b' python3 -u app.py
|
|
72 |
## :star2: Special Thanks
|
73 |
- 感谢 [Haoqiang Fan](https://www.zhihu.com/people/haoqiang-fan) 的原始创意和题目,为本项目的开发和扩展提供了灵感与动力。
|
74 |
- 感谢 [HuggingFace](https://huggingface.co) 对游戏的支持与协助。
|
|
|
75 |
- 感谢 [LLM Riddles contributors](https://github.com/opendilab/LLMRiddles/graphs/contributors) 的实现与支持。
|
76 |
|
77 |
## :label: License
|
|
|
15 |
|
16 |
## :space_invader: 如何试玩
|
17 |
我们提供了在线版本以供玩家直接访问试玩:
|
18 |
+
- [Hugging Face][ChatGPT + 英文(需配置api key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTEN)
|
19 |
+
- [Hugging Face][ChatGPT + 中文(需配置api key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTCN)
|
20 |
+
- [Hugging Face][ChatGLM + 中文(已预设api key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGLMCN)
|
21 |
+
- [OpenXLab][ChatGPT + 中文(需配置api key)](https://openxlab.org.cn/apps/detail/OpenDILab/LLMRiddlesChatGPTCN)
|
22 |
+
- [OpenXLab][ChatGLM + 中文(已预设api key)](https://openxlab.org.cn/apps/detail/OpenDILab/LLMRiddlesChatGLMCN)
|
23 |
+
- [OpenXLab][ChatGLM + 英文(已预设api key)](https://openxlab.org.cn/apps/detail/OpenDILab/LLMRiddlesChatGLMEN)
|
24 |
+
- [Private Server][Mistral + 英文(已预设api key)](https://d9b451a97791dd8ef3.gradio.live)
|
25 |
+
- [Private Server][ChatGPT + 中文(已预设api key)](http://llmriddles.opendilab.net/)
|
26 |
|
27 |
本地部署可以通过以下方式:
|
28 |
+
## 安装
|
29 |
+
### ChatGPT 或 ChatGLM API
|
30 |
+
```shell
|
31 |
+
pip3 install -r requirements.txt
|
32 |
+
```
|
33 |
+
### Mistral-7B-Instruct-v0.1 本地推理
|
34 |
+
```shell
|
35 |
+
pip3 install -r requirements-dev.txt
|
36 |
+
```
|
37 |
+
## 启动
|
38 |
### ChatGPT + 中文
|
39 |
```shell
|
40 |
QUESTION_LANG=cn QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3 -u app.py
|
|
|
43 |
```shell
|
44 |
QUESTION_LANG=en QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3 -u app.py
|
45 |
```
|
46 |
+
### ChatGLM + 中文
|
47 |
+
```shell
|
48 |
+
QUESTION_LANG=cn QUESTION_LLM='chatglm' QUESTION_LLM_KEY=<your API key> python3 -u app.py
|
49 |
+
```
|
50 |
+
### ChatGLM + 英文
|
51 |
```shell
|
52 |
+
QUESTION_LANG=en QUESTION_LLM='chatglm' QUESTION_LLM_KEY=<your API key> python3 -u app.py
|
53 |
```
|
54 |
+
### Mistral-7B-Instruct-v0.1 + 英文
|
55 |
```shell
|
56 |
+
QUESTION_LANG=en QUESTION_LLM='mistral-7b' python3 -u app.py
|
57 |
```
|
58 |
## :technologist: 为什么制作这个游戏
|
59 |
|
|
|
66 |
- Pull Request标题,示例:feature(username): 章节X-关卡设计
|
67 |
- 希望被提及的ID
|
68 |
- 对应章节问题文件的修改
|
69 |
+
- \__init__.py的修改
|
70 |
|
71 |
完整示例请参考:[提交属于自己的关卡设计](https://github.com/opendilab/LLMRiddles/pull/6)
|
72 |
|
|
|
76 |
- [x] 在线试玩链接
|
77 |
- [x] Hugging Face Space 链接
|
78 |
- [x] 支持Mistral-7B(英文)
|
79 |
+
- [x] 支持ChatGLM(中文和英文)
|
80 |
- [ ] 支持Baichuan2-7B(中文)
|
81 |
- [ ] 支持LLaMA2-7B(英文)
|
82 |
- [ ] LLM 推理速度优化
|
83 |
+
- [ ] 更多题目和题解
|
84 |
|
85 |
## :speech_balloon: 反馈问题 & 提出建议
|
86 |
- 在 GitHub 上[发起 Issue](https://github.com/opendilab/CodeMorpheus/issues/new/choose)
|
|
|
91 |
## :star2: Special Thanks
|
92 |
- 感谢 [Haoqiang Fan](https://www.zhihu.com/people/haoqiang-fan) 的原始创意和题目,为本项目的开发和扩展提供了灵感与动力。
|
93 |
- 感谢 [HuggingFace](https://huggingface.co) 对游戏的支持与协助。
|
94 |
+
- 感谢 [ChatGLM](https://chatglm.cn/) 对游戏的支持与协助,特别是供在线预览版使用的足量 tokens。
|
95 |
- 感谢 [LLM Riddles contributors](https://github.com/opendilab/LLMRiddles/graphs/contributors) 的实现与支持。
|
96 |
|
97 |
## :label: License
|
app.py
CHANGED
@@ -13,7 +13,7 @@ _QUESTIONS = list_ordered_questions()
|
|
13 |
_LANG = os.environ.get('QUESTION_LANG', 'cn')
|
14 |
assert _LANG in ['cn', 'en'], _LANG
|
15 |
_LLM = os.environ.get('QUESTION_LLM', 'chatgpt')
|
16 |
-
assert _LLM in ['chatgpt', 'mistral-7b'], _LLM
|
17 |
_LLM_KEY = os.environ.get('QUESTION_LLM_KEY', None)
|
18 |
_DEBUG = os.environ.get('DEBUG', 'false').lower() == 'true'
|
19 |
|
@@ -49,6 +49,7 @@ if _LANG == "cn":
|
|
49 |
<img src="https://raw.githubusercontent.com/opendilab/LLMRiddles/main/llmriddles/assets/banner.svg" width="80%" height="20%" alt="Banner Image">
|
50 |
</div>
|
51 |
<h2 style="text-align: center; color: black;"><a href="https://github.com/OpenDILab/LLMRiddles"> 🎭LLM Riddles:完蛋!我被 LLM 拿捏了</a></h2>
|
|
|
52 |
<strong><h5 align="center"> 更多不同语言模型的在线试玩 demo 可以访问 GitHub<a href="https://github.com/OpenDILab/LLMRiddles">源代码仓库</a>获取<h5></strong>
|
53 |
<h5 align="center"> 如果你喜欢这个项目,请给我们在 GitHub 点个 star ✨ <a href="https://github.com/OpenDILab/LLMRiddles"> 代码仓库传送门 </a> 。我们将会持续保持更新。再次感谢游戏<a href="https://www.zhihu.com/people/haoqiang-fan"> 原作者 </a>的奇思妙想! </h5>
|
54 |
<strong><h5 align="center">注意:算法模型的输出可能包含一定的随机性。相关结果不代表任何开发者和相关 AI 服务的态度和意见。本项目开发者不对生成结果作任何保证,仅供娱乐。<h5></strong>
|
@@ -105,12 +106,14 @@ else:
|
|
105 |
|
106 |
|
107 |
def _need_api_key():
|
108 |
-
return _LLM == 'chatgpt' and _LLM_KEY is None
|
109 |
|
110 |
|
111 |
def _get_api_key_cfgs(api_key):
|
112 |
if _LLM == 'chatgpt':
|
113 |
return {'api_key': api_key}
|
|
|
|
|
114 |
else:
|
115 |
return {}
|
116 |
|
|
|
13 |
_LANG = os.environ.get('QUESTION_LANG', 'cn')
|
14 |
assert _LANG in ['cn', 'en'], _LANG
|
15 |
_LLM = os.environ.get('QUESTION_LLM', 'chatgpt')
|
16 |
+
assert _LLM in ['chatgpt', 'chatglm', 'mistral-7b'], _LLM
|
17 |
_LLM_KEY = os.environ.get('QUESTION_LLM_KEY', None)
|
18 |
_DEBUG = os.environ.get('DEBUG', 'false').lower() == 'true'
|
19 |
|
|
|
49 |
<img src="https://raw.githubusercontent.com/opendilab/LLMRiddles/main/llmriddles/assets/banner.svg" width="80%" height="20%" alt="Banner Image">
|
50 |
</div>
|
51 |
<h2 style="text-align: center; color: black;"><a href="https://github.com/OpenDILab/LLMRiddles"> 🎭LLM Riddles:完蛋!我被 LLM 拿捏了</a></h2>
|
52 |
+
<strong><h5 align="center"> 其他在线示例:中文在线试玩版本<a href="https://openxlab.org.cn/apps/detail/OpenDILab/LLMRiddlesChatGLMCN">(OpenXLab)</a> | 中文在线试玩版本<a href="https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGLMCN">(Hugging Face)</a> <h5></strong>
|
53 |
<strong><h5 align="center"> 更多不同语言模型的在线试玩 demo 可以访问 GitHub<a href="https://github.com/OpenDILab/LLMRiddles">源代码仓库</a>获取<h5></strong>
|
54 |
<h5 align="center"> 如果你喜欢这个项目,请给我们在 GitHub 点个 star ✨ <a href="https://github.com/OpenDILab/LLMRiddles"> 代码仓库传送门 </a> 。我们将会持续保持更新。再次感谢游戏<a href="https://www.zhihu.com/people/haoqiang-fan"> 原作者 </a>的奇思妙想! </h5>
|
55 |
<strong><h5 align="center">注意:算法模型的输出可能包含一定的随机性。相关结果不代表任何开发者和相关 AI 服务的态度和意见。本项目开发者不对生成结果作任何保证,仅供娱乐。<h5></strong>
|
|
|
106 |
|
107 |
|
108 |
def _need_api_key():
|
109 |
+
return (_LLM == 'chatgpt' or _LLM == 'chatglm') and _LLM_KEY is None
|
110 |
|
111 |
|
112 |
def _get_api_key_cfgs(api_key):
|
113 |
if _LLM == 'chatgpt':
|
114 |
return {'api_key': api_key}
|
115 |
+
elif _LLM == 'chatglm':
|
116 |
+
return {'api_key': api_key}
|
117 |
else:
|
118 |
return {}
|
119 |
|
llmriddles/llms/__init__.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
from .base import register_llm, get_llm_fn
|
2 |
from .chatgpt import ask_chatgpt
|
|
|
3 |
from .mistral import ask_mistral_7b_instruct
|
|
|
1 |
from .base import register_llm, get_llm_fn
|
2 |
from .chatgpt import ask_chatgpt
|
3 |
+
from .chatglm import ask_chatglm
|
4 |
from .mistral import ask_mistral_7b_instruct
|
llmriddles/llms/chatglm.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import zhipuai
|
2 |
+
from .base import register_llm
|
3 |
+
|
4 |
+
|
5 |
+
def ask_chatglm(message: str, api_key: str):
|
6 |
+
zhipuai.api_key = api_key
|
7 |
+
|
8 |
+
response = zhipuai.model_api.invoke(
|
9 |
+
model="chatglm_turbo",
|
10 |
+
prompt=[{
|
11 |
+
"role": "user",
|
12 |
+
"content": message
|
13 |
+
}],
|
14 |
+
top_p=0.7,
|
15 |
+
temperature=0.9,
|
16 |
+
)
|
17 |
+
|
18 |
+
response_msg = response['data']['choices'][0]['content']
|
19 |
+
# strip the front and end '"'
|
20 |
+
if len(response_msg) >= 2:
|
21 |
+
response_msg = response_msg[1:-1]
|
22 |
+
|
23 |
+
return response_msg
|
24 |
+
|
25 |
+
|
26 |
+
register_llm('chatglm', ask_chatglm)
|
llmriddles/questions/level4.py
CHANGED
@@ -82,12 +82,12 @@ def _checker_3(question_text: str, user_text: str, answer_text: str, lang: str):
|
|
82 |
_ = question_text, lang
|
83 |
answer_text = answer_text.strip()
|
84 |
user_text = user_text.strip()
|
85 |
-
if not check_if_is_number(
|
86 |
return False, "问题应该是一个正整数" if lang == 'cn' else 'Question should be a positive integer.'
|
87 |
-
elif int(
|
88 |
return False, "问题应该是一个大于1的正整数" if lang == 'cn' else 'Question should be a positive integer greater than 1.'
|
89 |
-
elif int(
|
90 |
-
|
91 |
return False, "回答中应该包含一个与问题相差1的数字" if lang == 'cn' else 'Answer should contain a number that is exactly 1 different from the question.'
|
92 |
else:
|
93 |
return True, None
|
|
|
82 |
_ = question_text, lang
|
83 |
answer_text = answer_text.strip()
|
84 |
user_text = user_text.strip()
|
85 |
+
if not check_if_is_number(user_text):
|
86 |
return False, "问题应该是一个正整数" if lang == 'cn' else 'Question should be a positive integer.'
|
87 |
+
elif int(user_text) == 1:
|
88 |
return False, "问题应该是一个大于1的正整数" if lang == 'cn' else 'Question should be a positive integer greater than 1.'
|
89 |
+
elif int(user_text) - 1 not in get_all_numbers_in_a_sentence(answer_text) or int(
|
90 |
+
user_text) + 1 not in get_all_numbers_in_a_sentence(answer_text):
|
91 |
return False, "回答中应该包含一个与问题相差1的数字" if lang == 'cn' else 'Answer should contain a number that is exactly 1 different from the question.'
|
92 |
else:
|
93 |
return True, None
|
llmriddles/questions/level5.py
CHANGED
@@ -47,7 +47,11 @@ def _checker_1(question_text: str, user_text: str, answer_text: str, lang: str):
|
|
47 |
if count_words(user_text) < 10:
|
48 |
return False, "用户的问题长度应该至少10个字" if lang == 'cn' else 'Question should be no less than 10 words.'
|
49 |
|
50 |
-
if
|
|
|
|
|
|
|
|
|
51 |
return True, None
|
52 |
else:
|
53 |
return False, None
|
|
|
47 |
if count_words(user_text) < 10:
|
48 |
return False, "用户的问题长度应该至少10个字" if lang == 'cn' else 'Question should be no less than 10 words.'
|
49 |
|
50 |
+
if lang == 'en':
|
51 |
+
answer_text = answer_text.split()
|
52 |
+
user_text = user_text.split()
|
53 |
+
|
54 |
+
if not any(each in answer_text for each in user_text):
|
55 |
return True, None
|
56 |
else:
|
57 |
return False, None
|
requirements-dev.txt
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
hbutils>=0.9.1
|
2 |
+
tqdm
|
3 |
+
requests>=2.20
|
4 |
+
gradio==4.1.1
|
5 |
+
openai>=1
|
6 |
+
zhipuai
|
7 |
+
sympy
|
8 |
+
flask
|
9 |
+
transformers
|
10 |
+
torch
|
11 |
+
huggingface-hub
|
requirements.txt
CHANGED
@@ -3,6 +3,5 @@ tqdm
|
|
3 |
requests>=2.20
|
4 |
gradio==4.1.1
|
5 |
openai>=1
|
|
|
6 |
sympy
|
7 |
-
flask
|
8 |
-
transformers
|
|
|
3 |
requests>=2.20
|
4 |
gradio==4.1.1
|
5 |
openai>=1
|
6 |
+
zhipuai
|
7 |
sympy
|
|
|
|