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