RockSky1 commited on
Commit
0710173
·
verified ·
1 Parent(s): 6462067

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -54
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
- # 📥 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
-
65
- gr.Markdown("""
66
- ---
67
- *Built with ❤️ by RockSky1 | Powered by Infinity AI Ecosystem*
68
- """)
69
 
70
- # 🏁 4. Launching the App
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()