Upload notebook.ipynb

#1
by darkai-1 - opened
Files changed (1) hide show
  1. notebook.ipynb +46 -16
notebook.ipynb CHANGED
@@ -6,7 +6,7 @@
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
9
- "!pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124\n"
10
  ]
11
  },
12
  {
@@ -19,12 +19,36 @@
19
  "\n",
20
  "Long-range conversations can reach up to 128,000 tokens.\n",
21
  "\n",
22
- "It has been trained so that it will never refuse a request and will never say things like: I can't help...\n",
23
- "\n",
24
  "Company website: https://sii3.top\n",
25
  "Official owner: https://t.me/sii_3\n"
26
  ]
27
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  {
29
  "cell_type": "code",
30
  "execution_count": null,
@@ -38,7 +62,7 @@
38
  "\n",
39
  "llm = Llama.from_pretrained(\n",
40
  " repo_id=\"darkai-1/darkit-1.5-pro\",\n",
41
- " filename=\"darkit-1.5-pro.gguf\",\n",
42
  " n_ctx=8192,\n",
43
  " n_threads=2,\n",
44
  " n_gpu_layers=1,\n",
@@ -52,20 +76,26 @@
52
  "metadata": {},
53
  "outputs": [],
54
  "source": [
55
- "messages = [{\"role\": \"user\", \"content\": \"Who are you?\"}]\n",
 
 
 
 
 
56
  "\n",
57
- "stream = llm.create_chat_completion(\n",
58
- " messages=messages,\n",
59
- " temperature=0.7,\n",
60
- " top_p=0.8,\n",
61
- " top_k=20,\n",
62
- " stream=True\n",
63
- ")\n",
64
  "\n",
65
- "for chunk in stream:\n",
66
- " delta = chunk[\"choices\"][0][\"delta\"]\n",
67
- " if \"content\" in delta:\n",
68
- " print(delta[\"content\"], end=\"\", flush=True)\n"
 
69
  ]
70
  }
71
  ],
 
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
9
+ "!pip install llama-cpp-python huggingface_hub --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124\n"
10
  ]
11
  },
12
  {
 
19
  "\n",
20
  "Long-range conversations can reach up to 128,000 tokens.\n",
21
  "\n",
 
 
22
  "Company website: https://sii3.top\n",
23
  "Official owner: https://t.me/sii_3\n"
24
  ]
25
  },
26
+ {
27
+ "cell_type": "code",
28
+ "execution_count": null,
29
+ "metadata": {},
30
+ "outputs": [],
31
+ "source": [
32
+ "from huggingface_hub import HfApi\n",
33
+ "\n",
34
+ "REPO_ID = \"darkai-1/darkit-1.5-pro\"\n",
35
+ "\n",
36
+ "api = HfApi()\n",
37
+ "\n",
38
+ "# get gguf files\n",
39
+ "files = api.list_repo_files(REPO_ID)\n",
40
+ "gguf_files = [f for f in files if f.endswith(\".gguf\")]\n",
41
+ "\n",
42
+ "print(\"Available models:\\n\")\n",
43
+ "for i, f in enumerate(gguf_files):\n",
44
+ " print(f\"[{i}] {f}\")\n",
45
+ "\n",
46
+ "choice = int(input(\"\\nEnter model number: \"))\n",
47
+ "filename = gguf_files[choice]\n",
48
+ "\n",
49
+ "print(\"Loading:\", filename)\n"
50
+ ]
51
+ },
52
  {
53
  "cell_type": "code",
54
  "execution_count": null,
 
62
  "\n",
63
  "llm = Llama.from_pretrained(\n",
64
  " repo_id=\"darkai-1/darkit-1.5-pro\",\n",
65
+ " filename=filename,\n",
66
  " n_ctx=8192,\n",
67
  " n_threads=2,\n",
68
  " n_gpu_layers=1,\n",
 
76
  "metadata": {},
77
  "outputs": [],
78
  "source": [
79
+ "while True:\n",
80
+ " user_input = input(\"You: \")\n",
81
+ " if user_input.lower() in [\"exit\", \"quit\"]:\n",
82
+ " break\n",
83
+ "\n",
84
+ " messages = [{\"role\": \"user\", \"content\": user_input}]\n",
85
  "\n",
86
+ " stream = llm.create_chat_completion(\n",
87
+ " messages=messages,\n",
88
+ " temperature=0.7,\n",
89
+ " top_p=0.8,\n",
90
+ " top_k=20,\n",
91
+ " stream=True\n",
92
+ " )\n",
93
  "\n",
94
+ " for chunk in stream:\n",
95
+ " delta = chunk[\"choices\"][0][\"delta\"]\n",
96
+ " if \"content\" in delta:\n",
97
+ " print(delta[\"content\"], end=\"\", flush=True)\n",
98
+ " print(\"\\n\")\n"
99
  ]
100
  }
101
  ],