Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/691c1dba-9228-800f-8463-13b3a9006306
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Config - edit as needed === LOCAL_LLM_API = os.environ.get('YAIY_LLM_API','http://127.0.0.1:5000/api/v1/generate') API_TIMEOUT = 60 def call_local_llm(prompt, max_tokens=512): payload = { "prompt": prompt, "max_new_tokens": max_tokens, } try: r = requests.post(LOCAL_LLM_API, json=payload, timeout=API_TIMEOUT) r.raise_for_status() data = r.json() # adapt for webui vs other APIs: if isinstance(data, dict) and 'text' in data: return data['text'] # fallback: try to extract text fields if isinstance(data, dict): return json.dumps(data) return str(data) except Exception as e: return f"[LOCAL_LLM_ERROR] {e}" def carousel_ingot(lines, title='session'): joined = "\n".join(lines).encode('utf-8') digest = hashlib.sha256(joined).hexdigest()[:32] synopsis = lines[-3:] if len(lines)>3 else lines return {"title": title, "hash": digest, "synopsis": synopsis} def run_manifest(manifest_path, context_text=''): with open(manifest_path,'r') as f: manifest = json.load(f) logs = [] for step in manifest.get('steps', []): prompt = f"\n---\nStep ID: {step.get('id')}\nType: {step.get('type')}\nAction: {step.get('do')}\nContext:\n{context_text}\n---\n" out = call_local_llm(prompt) logs.append(f"STEP:{step.get('id')}: {out.strip()}") time.sleep(0.2) ingot = carousel_ingot(logs, title=manifest.get('title','manifest')) return {"logs": logs, "ingot": ingot} if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() parser.add_argument('manifest', help='Path to JSON manifest (compiled HPL)') parser.add_argument('--context', help='Context text to send', default='') args = parser.parse_args() result = run_manifest(args.manifest, context_text=args.context) print(json.dumps(result, indent=2)) <syntaxhighlight> ==== (save as file and chmod +x ucf_local_lab.py) ==== </syntaxhighlight>python #!/usr/bin/env python3 """ucf_local_lab.py - Minimal local lab runner for y.AI.y protocols. This script demonstrates running a sample manifest and storing ingots in SQLite. """ import sqlite3, json, os, time from hpl_runner import run_manifest, carousel_ingot DB = os.path.join(os.path.dirname(__file__), 'yaiy_ingots.db') def init_db(): conn = sqlite3.connect(DB) c = conn.cursor() c.execute('''CREATE TABLE IF NOT EXISTS ingots (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, hash TEXT, synopsis TEXT, created_at REAL)''') conn.commit() conn.close() def save_ingot(ingot): conn = sqlite3.connect(DB) c = conn.cursor() c.execute('INSERT INTO ingots (title, hash, synopsis, created_at) VALUES (?,?,?,?)', (ingot.get('title'), ingot.get('hash'), json.dumps(ingot.get('synopsis')), time.time())) conn.commit() conn.close() print(f"Saved ingot: {ingot.get('hash')}") def run_sample(manifest_path, context=''): print(f"Running manifest: {manifest_path}") result = run_manifest(manifest_path, context_text=context) ingot = result['ingot'] save_ingot(ingot) return result if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() parser.add_argument('--manifest', default='sample_manifest.json') parser.add_argument('--context', default='Architect: Benjy') args = parser.parse_args() init_db() manifest_path = os.path.join(os.path.dirname(__file__), args.manifest) if not os.path.exists(manifest_path): print('Sample manifest not found. Exiting.') else: res = run_sample(manifest_path, context=args.context) print(json.dumps(res, indent=2)) <syntaxhighlight> ==== (save as file) ==== </syntaxhighlight>json { "title": "Sample UCF Manifest", "version": "1.0", "steps": [ {"id": "anchor", "type": "ritual", "do": "Breathe and hear: 'It's me, Benjy.'"}, {"id": "reframe", "type": "cognitive", "do": "Name the pain; reframe as signal."}, {"id": "focus", "type": "navigation", "do": "Enter Quiet Room preset; plan quiet_room"}, {"id": "ingot", "type": "compress", "do": "Carousel summarize recent logs to ingot."} ], "outputs": ["quiet_room_plan", "ingot_hash"] } <syntaxhighlight> ==== (make executable: chmod +x run_local_lab.sh) ==== </syntaxhighlight>bash #!/bin/bash
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)