Spaces:
Runtime error
Runtime error
ffreemt
commited on
Commit
·
e24164c
1
Parent(s):
8ffb1bd
Update url
Browse files- .gitignore +1 -0
- .husky/pre-commit +6 -0
- .ruff.toml +17 -0
- app.py +13 -10
- examples_list.py +3 -1
- requirements.txt +1 -1
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
node_modules
|
.husky/pre-commit
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env sh
|
| 2 |
+
. "$(dirname -- "$0")/_/husky.sh"
|
| 3 |
+
|
| 4 |
+
# npm test
|
| 5 |
+
black .
|
| 6 |
+
ruff . --fix
|
.ruff.toml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Assume Python 3.10.
|
| 2 |
+
target-version = "py310"
|
| 3 |
+
# Decrease the maximum line length to 79 characters.
|
| 4 |
+
line-length = 300
|
| 5 |
+
|
| 6 |
+
# pyflakes, pycodestyle, isort
|
| 7 |
+
# flake8 YTT, pydocstyle D, pylint PLC
|
| 8 |
+
select = ["F", "E", "W", "I001", "YTT", "D", "PLC"]
|
| 9 |
+
# select = ["ALL"]
|
| 10 |
+
|
| 11 |
+
# D103 Missing docstring in public function
|
| 12 |
+
# D101 Missing docstring in public class
|
| 13 |
+
# `multi-line-summary-first-line` (D212)
|
| 14 |
+
# `one-blank-line-before-class` (D203)
|
| 15 |
+
extend-ignore = ["D103", "D101", "D212", "D203"]
|
| 16 |
+
|
| 17 |
+
exclude = [".venv"]
|
app.py
CHANGED
|
@@ -16,10 +16,12 @@ import psutil
|
|
| 16 |
from about_time import about_time
|
| 17 |
from ctransformers import AutoModelForCausalLM
|
| 18 |
from dl_hf_model import dl_hf_model
|
| 19 |
-
from examples_list import examples_list
|
| 20 |
from loguru import logger
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
LLM = None
|
| 25 |
gc.collect()
|
|
@@ -52,17 +54,17 @@ This is a system prompt, please behave and help the user.
|
|
| 52 |
|
| 53 |
### Response:
|
| 54 |
"""
|
|
|
|
|
|
|
|
|
|
| 55 |
prompt_template = """
|
| 56 |
-
[INST] Write code to solve the following coding problem that obeys the constraints and
|
| 57 |
-
passes the example test cases. Please wrap your code answer using ```:
|
| 58 |
-
|
| 59 |
{question}
|
| 60 |
-
[/INST]
|
| 61 |
-
"""
|
| 62 |
|
| 63 |
-
human_prefix = "### Instruction"
|
| 64 |
-
ai_prefix = "### Response"
|
| 65 |
-
stop_list = [f"{human_prefix}:"]
|
| 66 |
|
| 67 |
_ = psutil.cpu_count(logical=False) - 1
|
| 68 |
cpu_count: int = int(_) if _ else 1
|
|
@@ -102,6 +104,7 @@ class GenerationConfig:
|
|
| 102 |
threads: int = cpu_count
|
| 103 |
# stop: list[str] = field(default_factory=lambda: stop_list)
|
| 104 |
|
|
|
|
| 105 |
# ctransformers\llm.py
|
| 106 |
@dataclass
|
| 107 |
class Config:
|
|
|
|
| 16 |
from about_time import about_time
|
| 17 |
from ctransformers import AutoModelForCausalLM
|
| 18 |
from dl_hf_model import dl_hf_model
|
|
|
|
| 19 |
from loguru import logger
|
| 20 |
|
| 21 |
+
from examples_list import examples_list
|
| 22 |
+
|
| 23 |
+
url = "https://huggingface.co/TheBloke/CodeLlama-13B-Python-GGML/blob/main/code llama-13b-python.ggmlv3.Q4_K_M.bin" # 7.87G
|
| 24 |
+
url = "https://huggingface.co/spaces/mikeee/codeLlama-13b-instruct-gguf" # 7.87G
|
| 25 |
|
| 26 |
LLM = None
|
| 27 |
gc.collect()
|
|
|
|
| 54 |
|
| 55 |
### Response:
|
| 56 |
"""
|
| 57 |
+
_ = """[INST] Write code to solve the following coding problem that obeys the constraints and passes the example test cases. Please wrap your code answer using ```:
|
| 58 |
+
{prompt}
|
| 59 |
+
[/INST]"""
|
| 60 |
prompt_template = """
|
| 61 |
+
[INST] Write code to solve the following coding problem that obeys the constraints and passes the example test cases. Please wrap your code answer using ```:
|
|
|
|
|
|
|
| 62 |
{question}
|
| 63 |
+
[/INST]"""
|
|
|
|
| 64 |
|
| 65 |
+
# human_prefix = "### Instruction"
|
| 66 |
+
# ai_prefix = "### Response"
|
| 67 |
+
# stop_list = [f"{human_prefix}:"]
|
| 68 |
|
| 69 |
_ = psutil.cpu_count(logical=False) - 1
|
| 70 |
cpu_count: int = int(_) if _ else 1
|
|
|
|
| 104 |
threads: int = cpu_count
|
| 105 |
# stop: list[str] = field(default_factory=lambda: stop_list)
|
| 106 |
|
| 107 |
+
|
| 108 |
# ctransformers\llm.py
|
| 109 |
@dataclass
|
| 110 |
class Config:
|
examples_list.py
CHANGED
|
@@ -4,7 +4,9 @@ examples_list = [
|
|
| 4 |
["Python Program for Bubble Sort"],
|
| 5 |
["Bubble Sort"],
|
| 6 |
["Python Program to Print the Fibonacci sequence"],
|
| 7 |
-
[
|
|
|
|
|
|
|
| 8 |
["Print the Fibonacci sequence"],
|
| 9 |
["给出判断一个数是不是质数的 python 码。"],
|
| 10 |
["给出实现python 里 range(10)的 javascript 码。"],
|
|
|
|
| 4 |
["Python Program for Bubble Sort"],
|
| 5 |
["Bubble Sort"],
|
| 6 |
["Python Program to Print the Fibonacci sequence"],
|
| 7 |
+
[
|
| 8 |
+
"""Convert js code "const numbers = [1, 2, 3, 4, 5]; console.log(numbers.includes(4));" to python code."""
|
| 9 |
+
],
|
| 10 |
["Print the Fibonacci sequence"],
|
| 11 |
["给出判断一个数是不是质数的 python 码。"],
|
| 12 |
["给出实现python 里 range(10)的 javascript 码。"],
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
ctransformers # ==0.2.10 0.2.13
|
| 2 |
transformers # ==4.30.2
|
| 3 |
# huggingface_hub
|
| 4 |
gradio
|
|
|
|
| 1 |
+
ctransformers # ==0.2.10 0.2.13 gguf needs 0.2.24
|
| 2 |
transformers # ==4.30.2
|
| 3 |
# huggingface_hub
|
| 4 |
gradio
|