xosski

Perseus no keys LLM

May 10th, 2026
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.33 KB | None | 0 0
  1. github.com/xosski/Perseus
  2. # Portable LLM Module
  3.  
  4. This folder provides a standard, portable LLM layer built using the existing Hades architecture.
  5.  
  6. ## What It Uses
  7.  
  8. - `llm_conversation_core.ConversationManager` when available, with a built-in local conversation manager fallback
  9. - `ollama` as the default strict local-only generation backend
  10. - A built-in local knowledge response path that keeps the app focused on learned sources when a generative model is not active
  11. - `offline_llm.OfflineLLM` as an optional enhanced fallback path only when installed and explicitly enabled
  12. - Online search augmentation for explicit/current-information questions, while still keeping the LLM provider local by default
  13.  
  14. ## Response Sophistication
  15.  
  16. - Intent profiling for each prompt (`technical`, `educational`, `strategic`, `analytical`, `feedback`)
  17. - Question decomposition that reasons through relevant `who`, `what`, `when`, `where`, `why`, and `how` dimensions before answering
  18. - Adaptive prompt contracts that favor candid, genuine feedback with clear reasoning and next steps
  19. - Response quality scoring that penalizes short, generic, flattering, unstructured, or low-reasoning answers
  20. - Single-pass response refinement when initial output quality is low
  21. - Strict local-only mode by default (Ollama first, learned-source knowledge response when needed)
  22. - Persistent self-improvement memory that learns from prior quality failures and injects corrective directives
  23. - Runtime session metrics (`success`, `fallbacks`, `average_quality`, `refinements_used`)
  24.  
  25. ## Knowledge Learning Behavior
  26.  
  27. - Source-site ingestion accepts RSS/Atom feeds and normal websites in one persistent list
  28. - Feeds ingest both the feed source and linked article URLs
  29. - Normal websites ingest the page plus a bounded set of same-site links so Perseus can learn from trusted sources without manual browsing
  30. - Each source is bounded to keep ingestion practical
  31. - Local folder ingestion reads supported text files from a knowledge folder into the same learning store
  32. - Chat learning stores useful user inputs and completed exchanges as local memory so future answers can adapt to the user's facts, preferences, and project context
  33. - Prompt enrichment pulls multiple relevant context snippets from learned web knowledge
  34. - Grounded responses are expected to include an `Ingested Context Used` section when context is available
  35. - Ingestion errors are handled per-source so one bad URL does not disable the learner for the whole session
  36.  
  37. ## Quick Start
  38.  
  39. Run desktop chat:
  40.  
  41. ```bash
  42. python cli.py
  43. ```
  44.  
  45. Run terminal chat:
  46.  
  47. ```bash
  48. python cli.py --terminal
  49. ```
  50.  
  51. ## Ollama Setup
  52.  
  53. Perseus is designed to use Ollama as the default local LLM provider. Ollama must be running **and** at least one model must be installed. If Ollama is running but has no models, Perseus will fall back to its basic local fallback responses.
  54.  
  55. 1. Install Ollama from <https://ollama.com/download>.
  56. 2. Start the Ollama server:
  57.  
  58. ```bash
  59. ollama serve
  60. ```
  61.  
  62. 3. In a second terminal, install a model:
  63.  
  64. ```bash
  65. ollama pull llama3.2
  66. ```
  67.  
  68. If your machine is low on RAM, try a smaller model:
  69.  
  70. ```bash
  71. ollama pull qwen2.5:1.5b
  72. ```
  73.  
  74. 4. Confirm Ollama sees the model:
  75.  
  76. ```bash
  77. ollama list
  78. ```
  79.  
  80. 5. Launch Perseus with the matching model:
  81.  
  82. ```bash
  83. python cli.py --terminal --provider ollama --model llama3.2
  84. ```
  85.  
  86. or, for the smaller model:
  87.  
  88. ```bash
  89. python cli.py --terminal --provider ollama --model qwen2.5:1.5b
  90. ```
  91.  
  92. ### Ollama Troubleshooting
  93.  
  94. - `Provider=fallback` means Perseus did not find a usable local Ollama model.
  95. - `HTTP Error 404` from Ollama usually means the requested model name is not installed. Run `ollama list`, then pass the exact installed model name with `--model`.
  96. - If `ollama list` is empty, install a model with `ollama pull llama3.2` or `ollama pull qwen2.5:1.5b`.
  97. - If Ollama is not reachable, start it with `ollama serve`.
  98. - In strict local-only mode, remote/cloud providers are blocked, so a missing Ollama model will use the built-in fallback instead of an online LLM.
  99. - The built-in fallback can answer simple chat and some basic general questions, but full ChatGPT-style arbitrary responses require an installed Ollama model.
  100.  
  101. Choose provider explicitly:
  102.  
  103. ```bash
  104. python cli.py --provider ollama --model llama3.2
  105. ```
  106.  
  107. Enable non-strict mode (allows fallbacks/remotes):
  108.  
  109. ```bash
  110. python cli.py --allow-fallbacks
  111. ```
  112.  
  113. Disable online search augmentation if you want a fully offline session:
  114.  
  115. ```bash
  116. python cli.py --no-online-search
  117. ```
  118.  
  119. Enable OfflineLLM fallback (only works with `--allow-fallbacks`):
  120.  
  121. ```bash
  122. python cli.py --allow-fallbacks --use-offline-fallback
  123. ```
  124.  
  125. ## Python Usage
  126.  
  127. ```python
  128. from LLM import PortableLLM
  129.  
  130. llm = PortableLLM()
  131. reply = llm.ask("Explain SQL injection prevention clearly.")
  132. print(reply)
  133.  
  134. # Metadata includes provider, model, quality score, refinement status,
  135. # and whether ingested web context was used.
  136. reply, meta = llm.ask_with_metadata("Design a practical appsec roadmap for a startup team.")
  137. print(meta)
  138.  
  139. # Ingest local knowledge files. By default this expects a `knowledge/` folder
  140. # beside this module, but you can pass any folder path.
  141. ingest_result = llm.ingest_folder("knowledge")
  142. print(ingest_result)
  143.  
  144. # Persist and ingest trusted source sites/feeds.
  145. llm.save_source_sites([
  146. "https://docs.python.org/3/",
  147. "https://krebsonsecurity.com/feed/",
  148. ])
  149. source_result = llm.ingest_source_sites()
  150. print(source_result)
  151.  
  152. print(llm.get_stats())
  153. llm.close()
  154. ```
  155.  
  156. ## Ingestion Notes
  157.  
  158. - The desktop UI has a `Knowledge Ingest` tab for source-site ingestion, manual URL ingestion, and local folder ingestion
  159. - The source-site list is stored in `knowledge_sources.json`; edit it in the UI or directly as JSON
  160. - Source sites can be RSS/Atom feeds or normal websites; normal websites are scanned for a bounded number of same-site links
  161. - The default startup local folders are `knowledge` and `Princess protocol`; use `--knowledge-folder` to override or `--no-auto-ingest-folders` to disable startup folder ingestion
  162. - Folder ingestion is recursive by default and supports `.txt`, `.md`, `.docx`, `.py`, `.json`, `.yaml`, `.yml`, `.csv`, `.html`, `.htm`, `.log`, `.typed`, and no-extension text files
  163. - Individual local files larger than 1 MB are skipped to keep ingestion responsive
  164. - User chat turns are learned into the same `llm_web_learning.db` store as `perseus://chat-memory/...` records
  165. - Source ingest reports both source success and linked page/article success counts
  166. - Learned content is stored in `llm_web_learning.db`
  167.  
  168. ## Portability Notes
  169.  
  170. - Defaults to strict local-only mode and prefers a local provider (`ollama`)
  171. - Online search is enabled by default for explicit or current-information lookup requests; use `--no-online-search` to disable it
  172. - If a generative model is not active, the built-in local path keeps the app centered on ingested knowledge instead of web browsing
  173. - In strict mode, remote providers are blocked and provider switching is limited to local providers
  174. - If local provider output is weak, one refinement pass is attempted before returning best local result
  175. - Optional non-strict behavior is available via CLI flags when you intentionally want fallback behavior
  176. - Stores chat history in `llm_portable_conversations.db` by default
  177. - Stores self-improvement episodes in `llm_self_improvement.db` to guide future prompting
  178.  
Tags: ai llm
Advertisement
Add Comment
Please, Sign In to add comment