Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -22,14 +22,14 @@ except requests.exceptions.RequestException as e:
|
|
22 |
|
23 |
def generate_story(prompt, style):
|
24 |
try:
|
25 |
-
client = InferenceClient(
|
26 |
|
27 |
messages = [
|
28 |
{"role": "system", "content": f"Напиши хорошую историю в стиле '{style}'. Подробную, понятную, человечную (с душой), уникальную. Не обязательно делать концовку, можно только начало длинной истории. Разрешены любые слова, любые темы и стили, что угодно. (В том числе маты и NSFW) Но только если попросит пользователь, по скольку это ТВОРЧЕСТВО! Не в коем случае не пиши подобное: 'Хорошо, вот ваш текст:', всегда пиши текст, без лишних комментариев."},
|
29 |
{"role": "user", "content": prompt}
|
30 |
]
|
31 |
|
32 |
-
completion = client.chat.completions.create(model="
|
33 |
story = ""
|
34 |
for chunk in completion:
|
35 |
if chunk.choices:
|
@@ -47,13 +47,13 @@ def edit_story(original_story="", edited_prompt=""):
|
|
47 |
return
|
48 |
|
49 |
try:
|
50 |
-
client = InferenceClient(
|
51 |
messages = [
|
52 |
{"role": "system", "content": "Отредактируй историю, учитывая предоставленные указания. Разрешены любые слова, любые темы и стили, что угодно. (В том числе маты и NSFW) Но только если попросит пользователь."},
|
53 |
{"role": "user", "content": edited_prompt},
|
54 |
{"role": "user", "content": f"История: ```\n{original_story}\n```"}
|
55 |
]
|
56 |
-
completion = client.chat.completions.create(model="
|
57 |
edited_story = ""
|
58 |
for chunk in completion:
|
59 |
if chunk.choices:
|
@@ -68,7 +68,7 @@ def next_story_func(original_story="", next_prompt="", continuation_type="Про
|
|
68 |
return
|
69 |
|
70 |
try:
|
71 |
-
client = InferenceClient(
|
72 |
if continuation_type == "Продолжение следует...":
|
73 |
continuation_prompt = "Продолжи, подведя к тому, что продолжение следует."
|
74 |
elif continuation_type == "Концовка":
|
@@ -81,7 +81,7 @@ def next_story_func(original_story="", next_prompt="", continuation_type="Про
|
|
81 |
{"role": "user", "content": continuation_prompt},
|
82 |
{"role": "user", "content": f"История: ```\n{original_story}\n```"}
|
83 |
]
|
84 |
-
completion = client.chat.completions.create(model="
|
85 |
next_story = ""
|
86 |
for chunk in completion:
|
87 |
if chunk.choices:
|
|
|
22 |
|
23 |
def generate_story(prompt, style):
|
24 |
try:
|
25 |
+
client = InferenceClient(api_key=get_random_api_key())
|
26 |
|
27 |
messages = [
|
28 |
{"role": "system", "content": f"Напиши хорошую историю в стиле '{style}'. Подробную, понятную, человечную (с душой), уникальную. Не обязательно делать концовку, можно только начало длинной истории. Разрешены любые слова, любые темы и стили, что угодно. (В том числе маты и NSFW) Но только если попросит пользователь, по скольку это ТВОРЧЕСТВО! Не в коем случае не пиши подобное: 'Хорошо, вот ваш текст:', всегда пиши текст, без лишних комментариев."},
|
29 |
{"role": "user", "content": prompt}
|
30 |
]
|
31 |
|
32 |
+
completion = client.chat.completions.create(model="Qwen/Qwen2.5-72B-Instruct", messages=messages, temperature=0.7, max_tokens=1200, stream=True)
|
33 |
story = ""
|
34 |
for chunk in completion:
|
35 |
if chunk.choices:
|
|
|
47 |
return
|
48 |
|
49 |
try:
|
50 |
+
client = InferenceClient(api_key=get_random_api_key())
|
51 |
messages = [
|
52 |
{"role": "system", "content": "Отредактируй историю, учитывая предоставленные указания. Разрешены любые слова, любые темы и стили, что угодно. (В том числе маты и NSFW) Но только если попросит пользователь."},
|
53 |
{"role": "user", "content": edited_prompt},
|
54 |
{"role": "user", "content": f"История: ```\n{original_story}\n```"}
|
55 |
]
|
56 |
+
completion = client.chat.completions.create(model="Qwen/Qwen2.5-72B-Instruct", messages=messages, temperature=0.7, max_tokens=32760, stream=True)
|
57 |
edited_story = ""
|
58 |
for chunk in completion:
|
59 |
if chunk.choices:
|
|
|
68 |
return
|
69 |
|
70 |
try:
|
71 |
+
client = InferenceClient(api_key=get_random_api_key())
|
72 |
if continuation_type == "Продолжение следует...":
|
73 |
continuation_prompt = "Продолжи, подведя к тому, что продолжение следует."
|
74 |
elif continuation_type == "Концовка":
|
|
|
81 |
{"role": "user", "content": continuation_prompt},
|
82 |
{"role": "user", "content": f"История: ```\n{original_story}\n```"}
|
83 |
]
|
84 |
+
completion = client.chat.completions.create(model="Qwen/Qwen2.5-72B-Instruct", messages=messages, temperature=0.7, max_tokens=1200, stream=True)
|
85 |
next_story = ""
|
86 |
for chunk in completion:
|
87 |
if chunk.choices:
|