Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,72 +2,61 @@ import gradio as gr
|
|
| 2 |
from huggingface_hub import hf_hub_download
|
| 3 |
from llama_cpp import Llama
|
| 4 |
|
| 5 |
-
# 📥
|
| 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 |
-
|
| 13 |
-
|
| 14 |
llm = Llama(
|
| 15 |
-
model_path=model_path,
|
| 16 |
-
n_ctx=512,
|
| 17 |
-
n_threads=
|
|
|
|
| 18 |
)
|
| 19 |
|
|
|
|
|
|
|
|
|
|
| 20 |
def chat_function(message, history):
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 65 |
-
gr.Markdown("""
|
| 66 |
-
---
|
| 67 |
-
*Built with ❤️ by RockSky1 | Powered by Infinity AI Ecosystem*
|
| 68 |
-
""")
|
| 69 |
|
| 70 |
-
|
| 71 |
-
if __name__ == "__main__":
|
| 72 |
-
demo.launch()
|
| 73 |
-
|
|
|
|
| 2 |
from huggingface_hub import hf_hub_download
|
| 3 |
from llama_cpp import Llama
|
| 4 |
|
| 5 |
+
# 📥 Model Download
|
|
|
|
| 6 |
model_path = hf_hub_download(
|
| 7 |
+
repo_id="RockSky1/Infinity_1.0",
|
| 8 |
filename="Infinity_1.0.gguf"
|
| 9 |
)
|
| 10 |
|
| 11 |
+
print("Loading model...")
|
| 12 |
+
|
| 13 |
llm = Llama(
|
| 14 |
+
model_path=model_path,
|
| 15 |
+
n_ctx=512,
|
| 16 |
+
n_threads=2,
|
| 17 |
+
n_batch=128
|
| 18 |
)
|
| 19 |
|
| 20 |
+
print("Model loaded ✅")
|
| 21 |
+
|
| 22 |
+
|
| 23 |
def chat_function(message, history):
|
| 24 |
+
try:
|
| 25 |
+
output = llm.create_chat_completion(
|
| 26 |
+
messages=[
|
| 27 |
+
{
|
| 28 |
+
"role": "system",
|
| 29 |
+
"content": "You are Infinity AI 🔥 created by Shivam Kumar (RockSky1) from Bihar, India."
|
| 30 |
+
},
|
| 31 |
+
*[
|
| 32 |
+
{"role": "user", "content": h[0]} if i % 2 == 0
|
| 33 |
+
else {"role": "assistant", "content": h[1]}
|
| 34 |
+
for i, h in enumerate(history)
|
| 35 |
+
],
|
| 36 |
+
{"role": "user", "content": message}
|
| 37 |
+
],
|
| 38 |
+
max_tokens=128,
|
| 39 |
+
temperature=0.7
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
reply = output["choices"][0]["message"]["content"]
|
| 43 |
+
|
| 44 |
+
except Exception as e:
|
| 45 |
+
reply = f"Error: {str(e)}"
|
| 46 |
+
|
| 47 |
+
return reply
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
with gr.Blocks() as demo:
|
| 51 |
+
gr.Markdown("# ♾️ Infinity-LLM v1.0 🚀")
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
gr.ChatInterface(
|
| 54 |
fn=chat_function,
|
| 55 |
examples=[
|
| 56 |
+
"Who is Shivam Kumar?",
|
| 57 |
+
"Tell me about Infinity-LLM.",
|
| 58 |
"Write a simple Python script."
|
| 59 |
+
]
|
|
|
|
| 60 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
+
demo.launch()
|
|
|
|
|
|
|
|
|