To recover your old ProBoards account, you need to request password recovery on this forum using your display name (the one that is shown on your posts). You will then get an email, be sure to check your junk email folders.
Join the IRC at #frutiger-aero-archive on LiberaChat for any account-related inquiries or contact the admin at daniele63web@hotmail.com.

If you have registered after the 7th of November or have never posted, you need to re-register.

OPEN SOURCE AI (coding language: python)

Forum for sharing your creative projects or what you are working on.
User avatar
sk8erboi1oh1 (Radiation-s)
Member
Member
Posts: 96
Joined: July 19, 2025
Status: I am radiation-s in minecraft. the evil resident of THE heroin tunnel.
Aesthetic: Frutiger Aqua/Terminal style
OS: Window 10
Music: jumpstyle, nightcore, eurovision

OPEN SOURCE AI (coding language: python)

Unread post by sk8erboi1oh1 (Radiation-s) »

import tkinter as tk

from tkinter import scrolledtext, ttk

import threading

import ollama

import json

import os

import requests



#THIS CODE IS STRICTLY RESTRICTED AND HAVE NO CONNECTIONS TO THE REAL CODE



# ===== System Prompts =====

ASSISTANT_SYSTEM_PROMPT = (

"You are a helpful, conversational AI assistant. "

"Always try to be clear, accurate, and concise. "

"If the user asks for code, output valid code blocks in Markdown. "

"Be friendly and supportive, but not overly casual."

)





MODELS = {

"Assistant": "gemma:2b", # General model

}



CHAT_LOG_FILE = "chatlog.json"



# --- Load / Save Chat ---

def save_chat():

with open(CHAT_LOG_FILE, "w", encoding="utf-8") as f:

json.dump(messages, f, indent=2)



def load_chat():

if os.path.exists(CHAT_LOG_FILE):

with open(CHAT_LOG_FILE, "r", encoding="utf-8") as f:

return json.load(f)

return []



# Initialize mode

current_mode = "Assistant"

messages = [{"role": "system", "content": SYSTEM_PROMPTS[current_mode]}]



# --- UI helpers ---

def chat_insert(text: str, tag: str = ""):

chat_window.config(state="normal")

chat_window.insert(tk.END, text, tag)

chat_window.see(tk.END)

chat_window.config(state="disabled")



def set_input_enabled(enabled: bool):

entry.config(state=("normal" if enabled else "disabled"))

send_btn.config(state=("normal" if enabled else "disabled"))

if enabled:

entry.focus_set()



def typewriter(prefix: str, body: str, tag: str = "bot", done_cb=None):

chat_window.config(state="normal")

chat_window.insert(tk.END, prefix, tag)

chat_window.config(state="disabled")

chat_window.see(tk.END)



idx = {"i": 0}



def step():

if idx["i"] < len(body):

chat_window.config(state="normal")

chat_window.insert(tk.END, body[idx["i"]], tag)

chat_window.config(state="disabled")

chat_window.see(tk.END)

idx["i"] += 1

root.after(18, step)

else:

chat_window.config(state="normal")

chat_window.insert(tk.END, "\n\n", tag)

chat_window.config(state="disabled")

chat_window.see(tk.END)

if done_cb:

done_cb()



step()



# --- Model call ---

def generate_reply():

global current_mode

try:

response = ollama.chat(

model=MODELS[current_mode],

messages=messages

)

bot_msg = response["message"]["content"]

except Exception as e:

bot_msg = f"[Error] {e}"



root.after(0, lambda: on_bot_reply(bot_msg))



def on_bot_reply(bot_msg: str):

def reenable():

messages.append({"role": "assistant", "content": bot_msg})

save_chat()

set_input_enabled(True)



prefix = "AI: " if current_mode != "SCP-079" else "SCP-079: "

typewriter(prefix, bot_msg, "bot", done_cb=reenable)



# --- Send handler ---

def send_message(event=None):

global messages

user_msg = entry.get()

if not user_msg.strip():

return



chat_insert(f"You: {user_msg}\n", "user")

entry.delete(0, tk.END)



if user_msg.upper() == "RESET LOGS":

messages = [{"role": "system", "content": SYSTEM_PROMPTS[current_mode]}]

save_chat()

chat_insert("\n[ All chat logs cleared. ]\n\n", "bot")

return



messages.append({"role": "user", "content": user_msg})

save_chat()



chat_insert("AI: ...\n", "typing")

set_input_enabled(False)

threading.Thread(target=generate_reply, daemon=True).start()



# --- Mode switch handler ---

def switch_mode(event=None):

global current_mode, messages

selected = mode_var.get()

current_mode = selected

messages = [{"role": "system", "content": SYSTEM_PROMPTS[current_mode]}]

save_chat()

chat_insert(f"\n[ Mode switched to {current_mode}. Logs reset. ]\n\n", "bot")



# --- Tkinter setup ---

root = tk.Tk()

root.title("Multi-Mode Chatbot")

root.geometry("720x520")

root.configure(bg="#1E1E1E")



# Chat window

chat_window = scrolledtext.ScrolledText(

root,

wrap=tk.WORD,

state="disabled",

bg="#1E1E1E",

fg="#00E5FF",

insertbackground="white",

font=("Consolas", 13)

)

chat_window.pack(padx=10, pady=10, fill=tk.BOTH, expand=True)

chat_window.bind("<Key>", lambda e: "break")



chat_window.tag_config("user", foreground="#FFFFFF")

chat_window.tag_config("bot", foreground="#00E5FF")

chat_window.tag_config("typing", foreground="#AAAAAA")



# Mode selector

mode_frame = tk.Frame(root, bg="#1E1E1E")

mode_frame.pack(fill=tk.X, padx=10)



tk.Label(mode_frame, text="Mode:", bg="#1E1E1E", fg="white").pack(side=tk.LEFT)

mode_var = tk.StringVar(value=current_mode)

mode_menu = ttk.Combobox(mode_frame, textvariable=mode_var, values=list(SYSTEM_PROMPTS.keys()), state="readonly")

mode_menu.pack(side=tk.LEFT, padx=5)

mode_menu.bind("<<ComboboxSelected>>", switch_mode)



# Input row

input_row = tk.Frame(root, bg="#1E1E1E")

input_row.pack(padx=10, pady=(0, 10), fill=tk.X)



entry = tk.Entry(input_row, bg="#2C2C2C", fg="white", insertbackground="white", font=("Consolas", 12))

entry.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=(0, 8))



send_btn = tk.Button(input_row, text="Submit", command=send_message, bg="#333333", fg="white")

send_btn.pack(side=tk.RIGHT)



entry.bind("<Return>", send_message)

entry.focus_set()



chat_insert("Chatbot ready. Type RESET LOGS to clear memory.\n\n", "bot")



root.mainloop()


Im Radiation-s in minecraft. yes i go with alot of names.
User avatar
Daniele63
Forum Founder
Forum Founder
Posts: 710
Joined: July 04, 2025
Gender: Male
OS: Windows 11 / Ubuntu
Music: EDM / Nightcore
Hobbies: Coding, Minecraft
Has thanked: 163 times
Been thanked: 156 times
Age: 25
Contact:
France

Re: OPEN SOURCE AI (coding language: python)

Unread post by Daniele63 »

Please do not post AI media in the future, my forum is not the place for this. I've also put in the rules to not do that.
Image
Enjoy Everything!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest