Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,54 +2,63 @@ import gradio as gr
|
|
| 2 |
from huggingface_hub import hf_hub_download
|
| 3 |
from llama_cpp import Llama
|
| 4 |
|
| 5 |
-
# ๐ฅ 1. Infinity Engine (Model) Download
|
| 6 |
-
#
|
| 7 |
model_path = hf_hub_download(
|
| 8 |
repo_id="RockSky1/Infinity_1.0",
|
| 9 |
filename="Infinity_1.0.gguf"
|
| 10 |
)
|
| 11 |
|
| 12 |
-
# ๐ง 2. Model Loading (
|
| 13 |
-
# n_ctx=
|
| 14 |
-
llm = Llama(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
def chat_function(message, history):
|
| 17 |
-
# ๐ญ System Prompt:
|
| 18 |
system_instruction = (
|
| 19 |
-
"You are Infinity 1.0, a powerful and
|
| 20 |
-
"You were developed by the expert AI Architect Shivam Kumar
|
|
|
|
| 21 |
"You are highly intelligent, logical, and helpful. Always give credit to your creator "
|
| 22 |
"Shivam Kumar if someone asks who made you. Represent the innovation of Bihar!"
|
| 23 |
)
|
| 24 |
|
| 25 |
-
# Prompt Formatting
|
| 26 |
full_prompt = f"System: {system_instruction}\nUser: {message}\nInfinity:"
|
| 27 |
|
| 28 |
-
#
|
| 29 |
response = llm(
|
| 30 |
full_prompt,
|
| 31 |
-
max_tokens=
|
| 32 |
stop=["User:", "System:", "\n"],
|
| 33 |
echo=False
|
| 34 |
)
|
| 35 |
|
| 36 |
return response["choices"][0]["text"].strip()
|
| 37 |
|
| 38 |
-
# โจ 3.
|
| 39 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 40 |
gr.Markdown("""
|
| 41 |
# โพ๏ธ Infinity-LLM v1.0
|
| 42 |
### ๐ Next-Gen Neural Engine by **Shivam Kumar (RockSky1)**
|
| 43 |
-
๐ *
|
| 44 |
|
| 45 |
---
|
| 46 |
**Welcome to the future.** Infinity-LLM is built for high-speed logic and creative intelligence.
|
| 47 |
-
Ask me anything!
|
| 48 |
""")
|
| 49 |
|
| 50 |
gr.ChatInterface(
|
| 51 |
fn=chat_function,
|
| 52 |
-
examples=[
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
cache_examples=False,
|
| 54 |
)
|
| 55 |
|
|
|
|
| 2 |
from huggingface_hub import hf_hub_download
|
| 3 |
from llama_cpp import Llama
|
| 4 |
|
| 5 |
+
# ๐ฅ 1. Infinity Engine (GGUF Model) Download
|
| 6 |
+
# RockSky1 ki repo se model file fetch ho rahi hai
|
| 7 |
model_path = hf_hub_download(
|
| 8 |
repo_id="RockSky1/Infinity_1.0",
|
| 9 |
filename="Infinity_1.0.gguf"
|
| 10 |
)
|
| 11 |
|
| 12 |
+
# ๐ง 2. Model Loading (Optimized for Free Tier)
|
| 13 |
+
# n_ctx=512 aur n_threads=1 isliye rakha hai taaki OOM crash na ho
|
| 14 |
+
llm = Llama(
|
| 15 |
+
model_path=model_path,
|
| 16 |
+
n_ctx=512,
|
| 17 |
+
n_threads=1
|
| 18 |
+
)
|
| 19 |
|
| 20 |
def chat_function(message, history):
|
| 21 |
+
# ๐ญ System Prompt: Personal Branding & Identity
|
| 22 |
system_instruction = (
|
| 23 |
+
"You are Infinity 1.0, a powerful and futuristic AI engine. "
|
| 24 |
+
"You were developed by the expert AI Architect Shivam Kumar, "
|
| 25 |
+
"also known as RockSky1, hailing from Bihar, India. "
|
| 26 |
"You are highly intelligent, logical, and helpful. Always give credit to your creator "
|
| 27 |
"Shivam Kumar if someone asks who made you. Represent the innovation of Bihar!"
|
| 28 |
)
|
| 29 |
|
| 30 |
+
# Prompt Formatting for the Model
|
| 31 |
full_prompt = f"System: {system_instruction}\nUser: {message}\nInfinity:"
|
| 32 |
|
| 33 |
+
# AI Response Generation
|
| 34 |
response = llm(
|
| 35 |
full_prompt,
|
| 36 |
+
max_tokens=256,
|
| 37 |
stop=["User:", "System:", "\n"],
|
| 38 |
echo=False
|
| 39 |
)
|
| 40 |
|
| 41 |
return response["choices"][0]["text"].strip()
|
| 42 |
|
| 43 |
+
# โจ 3. Premium UI with Markdown & Emojis
|
| 44 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 45 |
gr.Markdown("""
|
| 46 |
# โพ๏ธ Infinity-LLM v1.0
|
| 47 |
### ๐ Next-Gen Neural Engine by **Shivam Kumar (RockSky1)**
|
| 48 |
+
๐ *Patna, Bihar, India* ๐ฎ๐ณ
|
| 49 |
|
| 50 |
---
|
| 51 |
**Welcome to the future.** Infinity-LLM is built for high-speed logic and creative intelligence.
|
| 52 |
+
Ask me anything about technology, coding, or my creator!
|
| 53 |
""")
|
| 54 |
|
| 55 |
gr.ChatInterface(
|
| 56 |
fn=chat_function,
|
| 57 |
+
examples=[
|
| 58 |
+
"Who is Shivam Kumar?",
|
| 59 |
+
"Tell me about Infinity-LLM.",
|
| 60 |
+
"Write a simple Python script."
|
| 61 |
+
],
|
| 62 |
cache_examples=False,
|
| 63 |
)
|
| 64 |
|