Spaces:
Sleeping
Sleeping
lenurseytasanov
commited on
Commit
·
448578b
1
Parent(s):
70d6111
Build character API v1
Browse files- .gitattributes +0 -35
- .gitignore +1 -0
- Dockerfile +16 -0
- Prompts.md +1 -0
- Prompts.png +0 -0
- app.py +33 -0
- requirements.txt +3 -0
.gitattributes
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.venv
|
Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
+
# you will also find guides on how best to write your Dockerfile
|
3 |
+
|
4 |
+
FROM python:3.9
|
5 |
+
|
6 |
+
RUN useradd -m -u 1000 user
|
7 |
+
USER user
|
8 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
9 |
+
|
10 |
+
WORKDIR /app
|
11 |
+
|
12 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
13 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
14 |
+
|
15 |
+
COPY --chown=user . /app
|
16 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
Prompts.md
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
### Instruction:\nWrite {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}. Use the provided character sheet and example dialogue for formatting direction and character speech patterns.\n\n{{#if system}}{{system}}\n\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n\n{{/if}}Description of {{char}}:\n{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n\n{{/if}}{{#if persona}}Description of {{user}}: {{persona}}\n\n{{/if}}Play the role of {{char}}\n\n{{#if wiAfter}}{{wiAfter}}\n{{/if}}
|
Prompts.png
ADDED
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
pipe = pipeline("text-generation", model="LakoMoor/Silicon-Masha-7B")
|
5 |
+
|
6 |
+
params = {
|
7 |
+
"temp": 0.3, "temperature_last": False, "top_p": 0.98, "top_k": 100, "top_a": 0, "tfs": 1, "epsilon_cutoff": 0, "eta_cutoff": 0,
|
8 |
+
"typical_p": 1, "min_p": 0.05, "rep_pen": 1.1, "rep_pen_range": 2048, "no_repeat_ngram_size": 0, "penalty_alpha": 0, "num_beams": 1,
|
9 |
+
"length_penalty": 1, "min_length": 0, "encoder_rep_pen": 1, "freq_pen": 0, "presence_pen": 0, "do_sample": True, "early_stopping": False,
|
10 |
+
"add_bos_token": True, "truncation_length": 2048, "ban_eos_token": False, "skip_special_tokens": True, "streaming": True, "mirostat_mode": 0,
|
11 |
+
"mirostat_tau": 5, "mirostat_eta": 0.1, "guidance_scale": 1, "negative_prompt": "", "grammar_string": "", "banned_tokens": "",
|
12 |
+
"ignore_eos_token_aphrodite": False, "spaces_between_special_tokens_aphrodite": True, "type": "koboldcpp", "legacy_api": False,
|
13 |
+
"sampler_order": [6, 0, 5, 3, 2, 1, 4], "n": 1, "rep_pen_size": 0, "genamt": 250, "max_length": 1024
|
14 |
+
}
|
15 |
+
|
16 |
+
app = FastAPI()
|
17 |
+
|
18 |
+
@app.post("/send")
|
19 |
+
async def stream(message):
|
20 |
+
char = "Lona Falldin"
|
21 |
+
user = "Unknown adventurer"
|
22 |
+
system = "Avoid repetition, don't loop. Develop the plot slowly, always stay in character. Describe all actions in full, elaborate, explicit, graphic, and vivid detail. Mention all relevant sensory perceptions."
|
23 |
+
description = ""
|
24 |
+
personality = ""
|
25 |
+
scenario = ""
|
26 |
+
main_prompt = f"### Instruction:\nWrite {char}'s next reply in a fictional roleplay chat between {user} and {char}. Use the provided character sheet and example dialogue for formatting direction and character speech patterns.\n\n{system}\n\nDescription of {char}:\n{description}\n{char}'s personality: {personality}\n\nScenario: {scenario}\n\nPlay the role of {char}"
|
27 |
+
prompt = f'''
|
28 |
+
Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
29 |
+
{main_prompt}
|
30 |
+
### User reply: {message.prompt.strip()}
|
31 |
+
### Response:'''
|
32 |
+
generated_texts = pipe(message, **params)
|
33 |
+
return generated_texts
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
fastapi
|
2 |
+
uvicorn[standard]
|
3 |
+
transformers
|