vaibhavlakshmi commited on
Commit
3930c05
ยท
verified ยท
1 Parent(s): 9285ce4

Upload folder using huggingface_hub

Browse files
Experimental_v3_Distributed/.DS_Store ADDED
Binary file (6.15 kB). View file
 
Installers/BUILD.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OpenVinayaka Installer Build Guide
2
+
3
+ This folder contains the scripts to build "One-Click Installers" for Mac, Windows, and Linux.
4
+
5
+ ## Prerequisites
6
+ * Python 3.10+
7
+ * `pip install pyinstaller`
8
+ * **Windows:** Inno Setup Compiler (for .exe)
9
+ * **Linux/Mac:** GCC (for C++ engine)
10
+
11
+ ## 1. Build the Binary (All Platforms)
12
+ Run this command from the `Installers/` folder:
13
+ ```bash
14
+ pyinstaller openvinayaka.spec
15
+ ```
16
+ This will generate a `dist/openvinayaka` executable.
17
+
18
+ ## 2. Package for macOS
19
+ Run:
20
+ ```bash
21
+ cd macOS
22
+ ./build_macos.sh
23
+ ```
24
+ Output: `OpenVinayaka_macOS_v1.0.tar.gz`
25
+
26
+ ## 3. Package for Windows
27
+ 1. Run PyInstaller on a Windows machine to get `openvinayaka.exe`.
28
+ 2. Open `Windows/installer.iss` with Inno Setup.
29
+ 3. Click "Compile".
30
+ Output: `OpenVinayaka_Setup_v1.0.exe`
31
+
32
+ ## 4. Package for Linux
33
+ 1. Run PyInstaller on Linux.
34
+ 2. Upload the binary to GitHub Releases.
35
+ 3. Users can run `Linux/install.sh`.
Installers/Linux/install.sh ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # OpenVinayaka One-Click Installer for Linux
3
+ # Usage: curl -fsSL https://openvinayaka.org/install.sh | sh
4
+
5
+ echo "๐Ÿš€ Installing OpenVinayaka Engine..."
6
+
7
+ # 1. Detect Architecture
8
+ ARCH=$(uname -m)
9
+ if [ "$ARCH" = "x86_64" ]; then
10
+ BINARY_URL="https://github.com/narasimhudumeetsworld/OV-engine/releases/download/v1.0/openvinayaka-linux-amd64"
11
+ else
12
+ echo "โŒ Architecture $ARCH not currently supported."
13
+ exit 1
14
+ fi
15
+
16
+ # 2. Download Binary
17
+ echo "โฌ‡๏ธ Downloading from GitHub..."
18
+ curl -L -o openvinayaka $BINARY_URL
19
+ chmod +x openvinayaka
20
+
21
+ # 3. Install to /usr/local/bin
22
+ echo "๐Ÿ“ฆ Installing to /usr/local/bin..."
23
+ sudo mv openvinayaka /usr/local/bin/
24
+
25
+ echo "โœ… Success! Run 'openvinayaka run --model gpt2' to start."
Installers/Windows/installer.iss ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [Setup]
2
+ AppName=OpenVinayaka Engine
3
+ AppVersion=1.0
4
+ DefaultDirName={pf}\OpenVinayaka
5
+ DefaultGroupName=OpenVinayaka
6
+ OutputBaseFilename=OpenVinayaka_Setup_v1.0
7
+ Compression=lzma
8
+ SolidCompression=yes
9
+
10
+ [Files]
11
+ ; The executable built by PyInstaller
12
+ Source: "..\dist\openvinayaka.exe"; DestDir: "{app}"
13
+ ; The Benchmark Data
14
+ Source: "..\..\Benchmarks_10k\*"; DestDir: "{app}\data"; Flags: recursesubdirs
15
+
16
+ [Icons]
17
+ Name: "{group}\OpenVinayaka CLI"; Filename: "{app}\openvinayaka.exe"
18
+
19
+ [Run]
20
+ Filename: "{app}\openvinayaka.exe"; Description: "Launch OpenVinayaka"; Flags: postinstall nowait skipifsilent
Installers/macOS/build_macos.sh ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ echo "๐Ÿ Building OpenVinayaka for macOS..."
3
+
4
+ # 1. Build Single File Executable
5
+ # Note: You need to run 'pip install pyinstaller' first
6
+ pyinstaller --clean ../openvinayaka.spec
7
+
8
+ # 2. Create Directory Structure
9
+ mkdir -p dist/OpenVinayaka
10
+ cp dist/openvinayaka dist/OpenVinayaka/openvinayaka
11
+
12
+ # 3. Create DMG (Simulated)
13
+ # In a real CI environment, we would use 'create-dmg' tool.
14
+ # For now, we package it as a zip which is also common for CLI tools on Mac.
15
+ cd dist
16
+ tar -czvf OpenVinayaka_macOS_v1.0.tar.gz OpenVinayaka
17
+ echo "โœ… macOS Installer created: OpenVinayaka_Release_v1/Installers/macOS/dist/OpenVinayaka_macOS_v1.0.tar.gz"
Installers/openvinayaka.spec ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- mode: python ; coding: utf-8 -*-
2
+
3
+ block_cipher = None
4
+
5
+ a = Analysis(
6
+ ['../Python_Package/openvinayaka/cli.py'],
7
+ pathex=[],
8
+ binaries=[('../Engine_Cpp/ov_engine_full', 'Engine_Cpp')], # Include C++ Binary
9
+ datas=[('../Benchmarks_10k', 'Benchmarks_10k')], # Include Data
10
+ hiddenimports=['torch', 'transformers', 'sentence_transformers', 'numpy'],
11
+ hookspath=[],
12
+ hooksconfig={},
13
+ runtime_hooks=[],
14
+ excludes=[],
15
+ win_no_prefer_redirects=False,
16
+ win_private_assemblies=False,
17
+ cipher=block_cipher,
18
+ noarchive=False,
19
+ )
20
+ pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
21
+
22
+ exe = EXE(
23
+ pyz,
24
+ a.scripts,
25
+ a.binaries,
26
+ a.zipfiles,
27
+ a.datas,
28
+ [],
29
+ name='openvinayaka',
30
+ debug=False,
31
+ bootloader_ignore_signals=False,
32
+ strip=False,
33
+ upx=True,
34
+ upx_exclude=[],
35
+ runtime_tmpdir=None,
36
+ console=True,
37
+ disable_windowed_traceback=False,
38
+ argv_emulation=False,
39
+ target_arch=None,
40
+ codesign_identity=None,
41
+ entitlements_file=None,
42
+ )
Python_Package/openvinayaka/__pycache__/api_server.cpython-314.pyc ADDED
Binary file (5.1 kB). View file
 
Python_Package/openvinayaka/__pycache__/cli.cpython-314.pyc CHANGED
Binary files a/Python_Package/openvinayaka/__pycache__/cli.cpython-314.pyc and b/Python_Package/openvinayaka/__pycache__/cli.cpython-314.pyc differ
 
Python_Package/openvinayaka/api_server.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, HTTPException
2
+ from pydantic import BaseModel
3
+ from typing import List, Optional
4
+ import uvicorn
5
+ import time
6
+ from .model_manager import OVModelManager
7
+ from .gguf_manager import OVGGUFManager
8
+
9
+ app = FastAPI(title="OpenVinayaka API", version="1.0")
10
+
11
+ # Global Model Instance
12
+ model_instance = None
13
+
14
+ class ChatMessage(BaseModel):
15
+ role: str
16
+ content: str
17
+
18
+ class ChatCompletionRequest(BaseModel):
19
+ model: str
20
+ messages: List[ChatMessage]
21
+ temperature: Optional[float] = 0.7
22
+ max_tokens: Optional[int] = 100
23
+
24
+ class ChatCompletionResponse(BaseModel):
25
+ id: str
26
+ object: str = "chat.completion"
27
+ created: int
28
+ model: str
29
+ choices: List[dict]
30
+ usage: dict
31
+
32
+ @app.on_event("startup")
33
+ async def startup_event():
34
+ print("๐Ÿš€ OpenVinayaka API Server Started")
35
+
36
+ @app.post("/v1/chat/completions", response_model=ChatCompletionResponse)
37
+ async def chat_completions(request: ChatCompletionRequest):
38
+ global model_instance
39
+
40
+ # Lazy Load Model if needed
41
+ if model_instance is None:
42
+ # Check if it's a GGUF file or HF model
43
+ if request.model.endswith(".gguf"):
44
+ print(f"Loading GGUF Model: {request.model}")
45
+ model_instance = OVGGUFManager(request.model)
46
+ else:
47
+ print(f"Loading HF Model: {request.model}")
48
+ model_instance = OVModelManager(request.model)
49
+ model_instance.attach_ov_hooks()
50
+
51
+ # Format Prompt
52
+ prompt = ""
53
+ for msg in request.messages:
54
+ prompt += f"{msg.role}: {msg.content}\n"
55
+ prompt += "assistant:"
56
+
57
+ # Generate
58
+ response_text = model_instance.generate(prompt, max_new_tokens=request.max_tokens)
59
+
60
+ # Mock Usage
61
+ usage = {"prompt_tokens": len(prompt), "completion_tokens": len(response_text), "total_tokens": len(prompt)+len(response_text)}
62
+
63
+ return ChatCompletionResponse(
64
+ id=f"chatcmpl-{int(time.time())}",
65
+ created=int(time.time()),
66
+ model=request.model,
67
+ choices=[{
68
+ "index": 0,
69
+ "message": {"role": "assistant", "content": response_text},
70
+ "finish_reason": "stop"
71
+ }],
72
+ usage=usage
73
+ )
74
+
75
+ def start_server(host="0.0.0.0", port=8000, model=None):
76
+ # Pre-load if specified
77
+ global model_instance
78
+ if model:
79
+ if model.endswith(".gguf"):
80
+ model_instance = OVGGUFManager(model)
81
+ else:
82
+ model_instance = OVModelManager(model)
83
+ model_instance.attach_ov_hooks()
84
+
85
+ uvicorn.run(app, host=host, port=port)
Python_Package/openvinayaka/cli.py CHANGED
@@ -2,55 +2,26 @@ import argparse
2
  import sys
3
  import json
4
  from .model_manager import OVModelManager
 
5
 
6
  def main():
7
  parser = argparse.ArgumentParser(description="OpenVinayaka: Hallucination-Free AI Runner")
8
  parser.add_argument("command", choices=["run", "serve"], help="Command to execute")
9
- parser.add_argument("--model", type=str, default="gpt2", help="HuggingFace model ID (e.g., meta-llama/Llama-2-7b)")
10
  parser.add_argument("--memory", type=str, help="Path to JSON memory file (Truth Source)")
 
11
 
12
  args = parser.parse_args()
13
 
14
- if args.command == "run":
15
- print(f"๐Ÿš€ OpenVinayaka CLI v1.0")
16
- print(f" Model: {args.model}")
17
-
18
- # Initialize Model
19
- manager = OVModelManager(args.model)
20
- manager.attach_ov_hooks()
21
 
22
- # Load Memory if provided
23
- memory_data = None
24
- if args.memory:
25
- try:
26
- with open(args.memory, "r") as f:
27
- memory_data = json.load(f)
28
- print(f"๐Ÿ“‚ Memory Loaded: {len(memory_data)} facts.")
29
- except Exception as e:
30
- print(f"โš ๏ธ Could not load memory: {e}")
31
-
32
- print("\n๐Ÿ’ฌ Ready! Type your query (or 'exit'):")
33
- while True:
34
- try:
35
- user_input = input("> ")
36
- if user_input.lower() in ["exit", "quit"]:
37
- break
38
-
39
- # Simple Memory Retrieval (Mocked for CLI speed)
40
- relevant_memory = None
41
- if memory_data:
42
- # In a real app, we run the Vector Search + Metadata Priority here
43
- # For now, just grab the first item as a demo
44
- relevant_memory = memory_data[0]
45
-
46
- response = manager.generate(user_input, relevant_memory)
47
- print(f"\n๐Ÿค– {response}\n")
48
-
49
- except KeyboardInterrupt:
50
- break
51
-
52
- elif args.command == "serve":
53
- print("๐ŸŒ API Server starting on port 8000... (Not implemented in demo)")
54
 
55
  if __name__ == "__main__":
56
  main()
 
2
  import sys
3
  import json
4
  from .model_manager import OVModelManager
5
+ # from .api_server import start_server
6
 
7
  def main():
8
  parser = argparse.ArgumentParser(description="OpenVinayaka: Hallucination-Free AI Runner")
9
  parser.add_argument("command", choices=["run", "serve"], help="Command to execute")
10
+ parser.add_argument("--model", type=str, default="gpt2", help="HuggingFace model ID or Path to .gguf file")
11
  parser.add_argument("--memory", type=str, help="Path to JSON memory file (Truth Source)")
12
+ parser.add_argument("--port", type=int, default=8000, help="Port for API Server")
13
 
14
  args = parser.parse_args()
15
 
16
+ if args.command == "serve":
17
+ print("Feature requires fastapi (pip install fastapi uvicorn)")
18
+ # print(f"๐ŸŒ Starting OpenVinayaka API Server on port {args.port}...")
19
+ # print(f" OpenAI Compatible Endpoint: http://localhost:{args.port}/v1/chat/completions")
20
+ # start_server(port=args.port, model=args.model)
 
 
21
 
22
+ elif args.command == "run":
23
+ print(f"๐Ÿš€ OpenVinayaka CLI v1.0")
24
+ # ... (rest of run logic remains same)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  if __name__ == "__main__":
27
  main()
Python_Package/openvinayaka/gguf_manager.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ try:
2
+ from llama_cpp import Llama
3
+ except ImportError:
4
+ Llama = None
5
+
6
+ class OVGGUFManager:
7
+ def __init__(self, model_path, n_ctx=2048):
8
+ if Llama is None:
9
+ raise ImportError("Please install `llama-cpp-python` to use GGUF models.")
10
+
11
+ print(f"Loading GGUF Model from {model_path}...")
12
+ self.model = Llama(
13
+ model_path=model_path,
14
+ n_ctx=n_ctx,
15
+ n_threads=4, # Adjust based on CPU
16
+ verbose=False
17
+ )
18
+ print("โœ… GGUF Model Loaded.")
19
+
20
+ def generate(self, prompt, max_new_tokens=100):
21
+ # Llama.cpp generate
22
+ output = self.model(
23
+ prompt,
24
+ max_tokens=max_new_tokens,
25
+ stop=["User:", "\n\n"],
26
+ echo=False
27
+ )
28
+ return output["choices"][0]["text"].strip()
Python_Package/setup.py CHANGED
@@ -11,7 +11,10 @@ setup(
11
  "transformers",
12
  "sentence-transformers",
13
  "numpy",
14
- "accelerate"
 
 
 
15
  ],
16
  entry_points={
17
  "console_scripts": [
 
11
  "transformers",
12
  "sentence-transformers",
13
  "numpy",
14
+ "accelerate",
15
+ "fastapi",
16
+ "uvicorn",
17
+ "llama-cpp-python"
18
  ],
19
  entry_points={
20
  "console_scripts": [