Update app.py
Browse files
app.py
CHANGED
@@ -4,32 +4,48 @@ from llama_cpp import Llama
|
|
4 |
llm = Llama(
|
5 |
model_path="yugogpt-q4_0.gguf",
|
6 |
n_ctx=2048,
|
7 |
-
n_threads=4
|
|
|
|
|
|
|
8 |
)
|
9 |
|
10 |
def chat(message, history):
|
11 |
-
# Enhanced prompt
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
"""
|
16 |
|
17 |
response = llm(
|
18 |
-
|
19 |
-
max_tokens=
|
20 |
-
temperature=0.
|
21 |
-
|
22 |
-
repeat_penalty=1.2,
|
23 |
-
|
|
|
24 |
)
|
25 |
|
26 |
return response['choices'][0]['text']
|
27 |
|
28 |
demo = gr.ChatInterface(
|
29 |
fn=chat,
|
30 |
-
title="YugoGPT
|
31 |
-
description="
|
|
|
|
|
|
|
|
|
|
|
32 |
)
|
33 |
|
34 |
if __name__ == "__main__":
|
35 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
|
|
|
4 |
llm = Llama(
|
5 |
model_path="yugogpt-q4_0.gguf",
|
6 |
n_ctx=2048,
|
7 |
+
n_threads=4,
|
8 |
+
n_batch=512,
|
9 |
+
use_mlock=True,
|
10 |
+
use_mmap=True
|
11 |
)
|
12 |
|
13 |
def chat(message, history):
|
14 |
+
# Enhanced system prompt for better responses
|
15 |
+
system_prompt = "You are a helpful, knowledgeable, and professional AI assistant. Provide detailed and thoughtful responses."
|
16 |
+
|
17 |
+
full_prompt = f"""SYSTEM: {system_prompt}
|
18 |
+
USER: {message}
|
19 |
+
ASSISTANT: Let me provide a comprehensive response.
|
20 |
"""
|
21 |
|
22 |
response = llm(
|
23 |
+
full_prompt,
|
24 |
+
max_tokens=2048,
|
25 |
+
temperature=0.7,
|
26 |
+
top_p=0.95,
|
27 |
+
repeat_penalty=1.2,
|
28 |
+
top_k=40,
|
29 |
+
stop=["USER:", "\n\n"]
|
30 |
)
|
31 |
|
32 |
return response['choices'][0]['text']
|
33 |
|
34 |
demo = gr.ChatInterface(
|
35 |
fn=chat,
|
36 |
+
title="YugoGPT Professional Assistant",
|
37 |
+
description="I provide detailed and thoughtful responses to your questions.",
|
38 |
+
examples=[
|
39 |
+
"Explain quantum computing",
|
40 |
+
"What are the main principles of machine learning?",
|
41 |
+
"How does blockchain technology work?"
|
42 |
+
]
|
43 |
)
|
44 |
|
45 |
if __name__ == "__main__":
|
46 |
+
demo.launch(
|
47 |
+
server_name="0.0.0.0",
|
48 |
+
server_port=7860,
|
49 |
+
share=False
|
50 |
+
)
|
51 |
+
|