Spaces:
Runtime error
Runtime error
is2win
commited on
Commit
·
e83fa87
1
Parent(s):
451aec3
new prompt
Browse files
app.py
CHANGED
|
@@ -10,11 +10,11 @@ from huggingface_hub import hf_hub_download
|
|
| 10 |
|
| 11 |
# Указываю имя репозитория и название скачиваемой модели
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
-
model_name = "lmstudio-community/Mistral-Nemo-Instruct-2407-GGUF"
|
| 17 |
-
model_file = "Mistral-Nemo-Instruct-2407-Q4_K_M.gguf"
|
| 18 |
|
| 19 |
|
| 20 |
# Загрузка с Hugging Face Hub
|
|
@@ -39,12 +39,29 @@ llm = LlamaCpp(
|
|
| 39 |
)
|
| 40 |
|
| 41 |
def predict(user_input):
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
"""
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
return output
|
| 49 |
|
| 50 |
# Создание интерфейса Gradio
|
|
@@ -52,4 +69,4 @@ demo = gr.Interface(fn=predict,
|
|
| 52 |
inputs="text",
|
| 53 |
outputs="text")
|
| 54 |
|
| 55 |
-
demo.launch()
|
|
|
|
| 10 |
|
| 11 |
# Указываю имя репозитория и название скачиваемой модели
|
| 12 |
|
| 13 |
+
model_name = "lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF"
|
| 14 |
+
model_file = "Meta-Llama-3.1-8B-Instruct-Q8_0.gguf"
|
| 15 |
|
| 16 |
+
# model_name = "lmstudio-community/Mistral-Nemo-Instruct-2407-GGUF"
|
| 17 |
+
# model_file = "Mistral-Nemo-Instruct-2407-Q4_K_M.gguf"
|
| 18 |
|
| 19 |
|
| 20 |
# Загрузка с Hugging Face Hub
|
|
|
|
| 39 |
)
|
| 40 |
|
| 41 |
def predict(user_input):
|
| 42 |
+
# Создаём простой шаблон
|
| 43 |
+
template = """
|
| 44 |
+
<|start_header_id|>system<|end_header_id|>
|
| 45 |
+
Вы личный ассистент по моде.
|
| 46 |
+
Рассуждаешь логически перед тем как дать ответ
|
| 47 |
+
Answer the question based only on the context
|
| 48 |
+
<|eot_id|>
|
| 49 |
+
<|start_header_id|>user<|end_header_id|>
|
| 50 |
+
Используй emoji и форматирование markdown текста чтобы иллюстрировать ответ
|
| 51 |
+
Отвечай на вопрос по пунктам как для новичков
|
| 52 |
+
Вопрос: {question}
|
| 53 |
+
<|eom_id|>
|
| 54 |
+
<|start_header_id|>assistant<|end_header_id|>
|
| 55 |
"""
|
| 56 |
+
# Используйте вашу модель для обработки запроса
|
| 57 |
+
try:
|
| 58 |
+
prompt = PromptTemplate.from_template(template)
|
| 59 |
+
chain = prompt | llm
|
| 60 |
+
|
| 61 |
+
output = chain.invoke({'question':user_input})
|
| 62 |
+
except Exception as e:
|
| 63 |
+
output = f"Ошибка: {str(e)}"
|
| 64 |
+
|
| 65 |
return output
|
| 66 |
|
| 67 |
# Создание интерфейса Gradio
|
|
|
|
| 69 |
inputs="text",
|
| 70 |
outputs="text")
|
| 71 |
|
| 72 |
+
demo.launch(debug=True)
|