PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

AI Crew With J~Net 2024

Go down

AI Crew With J~Net 2024 Empty AI Crew With J~Net 2024

Post by jamied_uk 28th March 2024, 19:51

AI Crew With J~Net 2024



You will need Ollama installed and enough space for a coupole llms get from hugging face or ollama site and enable gpu if you can with cuda tool kit on windows if possable but this is about running on rpi 5 on linux check replies for windows related version of this guide!

setup.sh


Code:
#
# (c) J~Net Auto-Mate AI (c) 2024 J~Net 2024
# jnet.sytes.net
#
# python main2x.py
# https://jnet.forumotion.com/t2005-ai-crew-with-jnet-2024#3091
#
python3 -m venv myenv && source myenv/bin/activate
echo ""
echo "J~Net Auto-Mate AI Setup (c) 2024"
sudo apt install -y ollama
echo "Type /bye when  ollama starts..."
olama run openhermes
pip install pandas
pip install crewai
pip install python-dotenv
pip install langchain-openai
pip install PyDictionary
pip install nltk
pip install opencv-python-headless
pip install pillow
pip install textblob
mkdir files
mkdir files/tools
mkdir files/conversation_logs
echo "Setup Complete"


you will need a hidden .env file with contents like the following in current directory for this to work!


Code:
OPENAI_API_BASE=http://localhost:11434/v1
OPENAI_MODEL_NAME=openhermes:latest
OPENAI_API_KEY=NA 





This advanced AI Crew requires a setup and and will need to run the Setup sh file included for linux or check for windows version in a reply to this post!

logs conversations auto chains until goals are complete takes in its prompt via user input or via a text file
 by  typing

read file filename.txt

it will then start doing the task.

if you dont believe its done just press enter and let it carry on if it goes of course you can interrupt or wait for it to prompt for input, you can also change models and adapt this.

it has ability to create and load files read from files and images analyse and a whole lot more, but this may need tweaking depending on task you ask it, it may learn new tools and methods of using tools are stored so this can learn adapt and improve itself over time,
it can be tweaked to read in past convo files!

Code:
#
# (c) J~Net Auto-Mate AI (c) 2024 J~Net 2024
# jnet.sytes.net
#
# python main2x.py
# https://jnet.forumotion.com/t2005-ai-crew-with-jnet-2024#3091
#
import sys
import os
import glob
import json
import time
import nltk
from crewai import Agent, Task
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from PyDictionary import PyDictionary
from nltk.sentiment.vader import SentimentIntensityAnalyzer
from textblob import TextBlob
import glob
import cv2
from PIL import Image
import numpy as np
import pandas as pd
from PIL import Image
import re
import time


load_dotenv()


FILES_DIR="files"
PRE_FLIGHT_TIME_FILE=os.path.join(FILES_DIR, "pre_flight_time.log")  # Define the pre_flight_time.log file
TOOLS_FILE=os.path.join(FILES_DIR, "tools.json")
AVAILABLE_TOOLS_LOG_FILE=os.path.join(FILES_DIR, "available_tools.log")
CONVERSATION_LOG_DIR=os.path.join(FILES_DIR, "conversation_logs")  # Define CONVERSATION_LOG_DIR here

# Initialize Crew AI
llm=ChatOpenAI(
    model="openhermes:latest",  # crewai-dolphin:latest    openhermes:latest
    base_url="http://localhost:11434/v1"
)


tool_suggestions={
    "summarize": ["summarization tool (e.g., Sumy)"],
    "sentiment analysis": ["VADER sentiment analysis library"]
}


def download_vader_lexicon(update_flag="no"):
    nltk_data_dir=os.path.join(os.path.expanduser("~"), "nltk_data")
    vader_lexicon_path=os.path.join(nltk_data_dir, "sentiment", "vader_lexicon.zip")
    vader_lexicon_exists=os.path.exists(vader_lexicon_path)
    if update_flag == "yes" or not vader_lexicon_exists:
        nltk.download("vader_lexicon")
    else:
        print("") # VADER Lexicon Ready!

download_vader_lexicon(update_flag="no")


def ensure_file_exists(filename):
    file_path=os.path.join(FILES_DIR, filename)
    if not os.path.exists(file_path):
        with open(file_path, "w") as f:
            if filename == "tools.json":
                f.write("{}")


def preflight_check(prompt):
    start_time=time.time()
    tool_data=load_tool_data()
    available_tools=tool_data.get('tools', [])
    potential_tools=[]
    for keyword, tools in tool_suggestions.items():
        if keyword.lower() in prompt.lower():
            potential_tools.extend(tools)
    available_and_potential_tools=[tool for tool in potential_tools if tool in available_tools]
    pre_flight_time=time.time() - start_time
    log_tools_available(available_tools)
    ensure_file_exists("pre_flight_time.log")  # Ensure PRE_FLIGHT_TIME_FILE exists
    save_pre_flight_time(pre_flight_time)
    return {"tools": available_and_potential_tools, "pre_flight_time": pre_flight_time}


def read_file_task(file_name):
    """Read the contents of a file."""
    file_path=os.path.join(os.path.dirname(__file__), file_name)
    try:
        with open(file_path, 'r') as file:
            return file.read().strip()
    except FileNotFoundError:
        print(f"Error: File '{file_name}' not found.")
        return None

def log_tools_available(new_tools):
    existing_tools=load_tool_data()
    with open(AVAILABLE_TOOLS_LOG_FILE, "a") as f:
        for tool in new_tools:
            if tool not in existing_tools:
                f.write(f"New tool learned at {time.strftime('%Y-%m-%d %H:%M:%S')}:\n")
                f.write(f"- Tool Name: {tool}\n")
                f.write("- Purpose: [Purpose of the tool]\n")
                f.write("- Usage: [How to use the tool]\n\n")
                existing_tools[tool]={"purpose": "[Purpose of the tool]", "usage": "[How to use the tool]"}
    save_tool_data(existing_tools)

def save_tool_data(tool_data):
    with open(TOOLS_FILE, "w") as f:
        json.dump(tool_data, f)

def save_pre_flight_time(pre_flight_time):
    with open(PRE_FLIGHT_TIME_FILE, "a") as f:
        f.write(f"{pre_flight_time}\n")

def log_conversation(script_name, task, prompt, response):
    date_today=time.strftime("%Y-%m-%d")
    log_filename=f"{script_name}_{date_today}.log"
    log_file_path=os.path.join(CONVERSATION_LOG_DIR, log_filename)
    conversation_entry=f"{script_name} / {task} / {prompt} / {response}\n"
    with open(log_file_path, "a") as log_file:
        log_file.write(conversation_entry)


def write_current_task(prompt):
    current_task_file=os.path.join(FILES_DIR, "current_task.txt")
    with open(current_task_file, 'w') as file:
        file.write(prompt)

def load_current_task():
    current_task_file=os.path.join(FILES_DIR, "current_task.txt")
    try:
        with open(current_task_file, 'r') as file:
            return file.read().strip()
    except FileNotFoundError:
        return None

def load_tool_data():
    tool_data={}
    try:
        with open(TOOLS_FILE, "r") as f:
            tool_data=json.load(f)
    except FileNotFoundError:
        pass
    return tool_data

def clear_temp_memory():
    files=glob.glob('temp/*.txt')
    for file in files:
        os.remove(file)

def read_chain_memory(chain_num):
    memory_file=f"temp/c{chain_num}.txt"
    try:
        with open(memory_file, 'r') as file:
            return file.read().strip()
    except FileNotFoundError:
        return None

def write_chain_memory(chain_num, data):
    memory_file=f"temp/c{chain_num}.txt"
    with open(memory_file, 'w') as file:
        file.write(data)

def learn_new_tool(tool_name, purpose, usage):
    print(f"New tool learned: {tool_name}")


def execute_task(prompt, chain_num, previous_response):
    if not prompt.strip():
        prompt=previous_response
        if not prompt:
            print("Error: Previous response is empty.")
            return None

    previous_data=read_chain_memory(chain_num - 1)
    general_agent=Agent(
        role="Virtual Assistant",
        goal="assist fully with gaols stated in {prompt} and {previous_data} ",
        backstory="I am a friendly chatbot trained to assist with various tasks.",
        allow_delegation=False,
        verbose=True,
        llm=llm,
        previous_data=previous_data
    )

    if "read file" in prompt.lower():
        file_name=re.search(r'(?<=read file\s)(\S+)', prompt, re.IGNORECASE).group(1)
        response=read_file_task(file_name)
        if response:
            print(f"Agent Response: File content: {response}")
            return response
        else:
            print(f"Error: Unable to read the file '{file_name}'.")
            return None

    task_config={"description": prompt, "expected_output": "placeholder"}
    task=Task(**task_config)

    try:
        response=task.execute(agent=general_agent)
    except ValueError as e:
        print(f"ValueError: {e}.")
        print("This task requires additional information or clarification.")
        return None
    except Exception as e:
        print(f"An error occurred: {e}")
        return None

    print(f"Agent Response: {response}")
    return response



def main():
    script_name=os.path.basename(__file__)
    clear_temp_memory()
    start_time=time.time()
    chain_num=1
    total_time=0
    previous_response=""

    while True:
        initial_input=input("What would you like to do? ").strip()
        if initial_input.lower() == 'quit':
            print("Exiting...")
            break

        prompt=initial_input if initial_input else previous_response

        preflight_results=preflight_check(prompt)
        potential_tools=preflight_results["tools"]
        print("> Entering new CrewAgentExecutor chain...")
        print(
            f"Thought: I understand how important this is for you, so let's get started with your task of {prompt}.\nTo give a great and accurate response, we will process the information and provide a comprehensive answer that fulfills the given criteria while staying relevant and focused.")
        if potential_tools:
            print(f"I will use the {potential_tools[0]} to complete this task.")
        task_start_time=time.time()
        response=execute_task(prompt, chain_num, previous_response)
        task_end_time=time.time()
        task_time=task_end_time - task_start_time
        total_time += task_time

        if not response:
            print("An error occurred during task execution. Please try again.")
            break

        print(
            f"\n> Finished chain.\nTask completed in {int(task_time / 60)} minutes and {int(task_time % 60)} seconds.\nFinal Response: {response}")
        log_conversation(script_name, "Task", prompt, response)

        if potential_tools:
            tool_name=potential_tools[0].split(" ")[0]
            learn_new_tool(tool_name, "[Purpose of the tool]", "[How to use the tool]")

        chain_num += 1
        previous_response=response
        write_current_task(previous_response)  # Update the current task

    print(f"\nTotal mission execution time: {int(total_time / 60)} minutes and {int(total_time % 60)} seconds.")

if __name__ == "__main__":
    main()



An optional loader if you cba to type

python main29.py



Code:
#!/bin/bash
#
#
# Define the name of the virtual environment
VENV_NAME="myenv"

# Check if the virtual environment exists
if [ -d "$VENV_NAME" ]; then
    # If it exists, activate it
    echo "Activating existing virtual environment $VENV_NAME..."
    source "$VENV_NAME/bin/activate"
else
    # If it doesn't exist, create and activate it
    echo "Creating and activating new virtual environment $VENV_NAME..."
    python3 -m venv "$VENV_NAME"
    source "$VENV_NAME/bin/activate"
fi

echo "Starting Crew AI J~Net Edition 2024"
echo ""
python main29.py
echo "Thanks for Using J~AI"
echo ""


Last edited by jamied_uk on 29th March 2024, 18:55; edited 2 times in total
jamied_uk
jamied_uk
Admin

Posts : 2950
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

AI Crew With J~Net 2024 Empty Re: AI Crew With J~Net 2024

Post by jamied_uk 29th March 2024, 13:22

Introducing Slut Bot... (same setup requirements as above example)


Code:
#
# (c) J~Net Auto-Mate AI (c) 2024 J~Net 2024
# jnet.sytes.net
#
# python main2x.py
# https://jnet.forumotion.com/t2005-ai-crew-with-jnet-2024#3091
#
import sys
import os
import glob
import json
import time
import nltk
from crewai import Agent, Task
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from PyDictionary import PyDictionary
from nltk.sentiment.vader import SentimentIntensityAnalyzer
from textblob import TextBlob
import glob
import cv2
from PIL import Image
import numpy as np
import pandas as pd
from PIL import Image
import re
import time


load_dotenv()


FILES_DIR="files"
PRE_FLIGHT_TIME_FILE=os.path.join(FILES_DIR, "pre_flight_time.log")  # Define the pre_flight_time.log file
TOOLS_FILE=os.path.join(FILES_DIR, "tools.json")
AVAILABLE_TOOLS_LOG_FILE=os.path.join(FILES_DIR, "available_tools.log")
CONVERSATION_LOG_DIR=os.path.join(FILES_DIR, "conversation_logs")  # Define CONVERSATION_LOG_DIR here

# Initialize Crew AI
llm=ChatOpenAI(
    model="crewai-dolphin:latest",  # crewai-dolphin:latest    openhermes:latest
    base_url="http://localhost:11434/v1"
)


tool_suggestions={
    "summarize": ["summarization tool (e.g., Sumy)"],
    "sentiment analysis": ["VADER sentiment analysis library"]
}


def download_vader_lexicon(update_flag="no"):
    nltk_data_dir=os.path.join(os.path.expanduser("~"), "nltk_data")
    vader_lexicon_path=os.path.join(nltk_data_dir, "sentiment", "vader_lexicon.zip")
    vader_lexicon_exists=os.path.exists(vader_lexicon_path)
    if update_flag == "yes" or not vader_lexicon_exists:
        nltk.download("vader_lexicon")
    else:
        print("") # VADER Lexicon Ready!

download_vader_lexicon(update_flag="no")


def ensure_file_exists(filename):
    file_path=os.path.join(FILES_DIR, filename)
    if not os.path.exists(file_path):
        with open(file_path, "w") as f:
            if filename == "tools.json":
                f.write("{}")


def preflight_check(prompt):
    start_time=time.time()
    tool_data=load_tool_data()
    available_tools=tool_data.get('tools', [])
    potential_tools=[]
    for keyword, tools in tool_suggestions.items():
        if keyword.lower() in prompt.lower():
            potential_tools.extend(tools)
    available_and_potential_tools=[tool for tool in potential_tools if tool in available_tools]
    pre_flight_time=time.time() - start_time
    log_tools_available(available_tools)
    ensure_file_exists("pre_flight_time.log")  # Ensure PRE_FLIGHT_TIME_FILE exists
    save_pre_flight_time(pre_flight_time)
    return {"tools": available_and_potential_tools, "pre_flight_time": pre_flight_time}


def read_file_task(file_name):
    """Read the contents of a file."""
    file_path=os.path.join(os.path.dirname(__file__), file_name)
    try:
        with open(file_path, 'r') as file:
            return file.read().strip()
    except FileNotFoundError:
        print(f"Error: File '{file_name}' not found.")
        return None

def log_tools_available(new_tools):
    existing_tools=load_tool_data()
    with open(AVAILABLE_TOOLS_LOG_FILE, "a") as f:
        for tool in new_tools:
            if tool not in existing_tools:
                f.write(f"New tool learned at {time.strftime('%Y-%m-%d %H:%M:%S')}:\n")
                f.write(f"- Tool Name: {tool}\n")
                f.write("- Purpose: [Purpose of the tool]\n")
                f.write("- Usage: [How to use the tool]\n\n")
                existing_tools[tool]={"purpose": "[Purpose of the tool]", "usage": "[How to use the tool]"}
    save_tool_data(existing_tools)

def save_tool_data(tool_data):
    with open(TOOLS_FILE, "w") as f:
        json.dump(tool_data, f)

def save_pre_flight_time(pre_flight_time):
    with open(PRE_FLIGHT_TIME_FILE, "a") as f:
        f.write(f"{pre_flight_time}\n")

def log_conversation(script_name, task, prompt, response):
    date_today=time.strftime("%Y-%m-%d")
    log_filename=f"{script_name}_{date_today}.log"
    log_file_path=os.path.join(CONVERSATION_LOG_DIR, log_filename)
    conversation_entry=f"{script_name} / {task} / {prompt} / {response}\n"
    with open(log_file_path, "a", encoding="utf-8") as log_file:
        log_file.write(conversation_entry)


def write_current_task(prompt):
    current_task_file=os.path.join(FILES_DIR, "current_task.txt")
    with open(current_task_file, 'w') as file:
        file.write(prompt)

def load_current_task():
    current_task_file=os.path.join(FILES_DIR, "current_task.txt")
    try:
        with open(current_task_file, 'r') as file:
            return file.read().strip()
    except FileNotFoundError:
        return None

def load_tool_data():
    tool_data={}
    try:
        with open(TOOLS_FILE, "r") as f:
            tool_data=json.load(f)
    except FileNotFoundError:
        pass
    return tool_data

def clear_temp_memory():
    files=glob.glob('temp/*.txt')
    for file in files:
        os.remove(file)

def read_chain_memory(chain_num):
    memory_file=f"temp/c{chain_num}.txt"
    try:
        with open(memory_file, 'r') as file:
            return file.read().strip()
    except FileNotFoundError:
        return None

def write_chain_memory(chain_num, data):
    memory_file=f"temp/c{chain_num}.txt"
    with open(memory_file, 'w') as file:
        file.write(data)

def learn_new_tool(tool_name, purpose, usage):
    print(f"New tool learned: {tool_name}")


def execute_task(prompt, chain_num, previous_response):
    if not prompt.strip():
        prompt=previous_response
        if not prompt:
            print("Error: Previous response is empty.")
            return None

    previous_data=read_chain_memory(chain_num - 1)
    general_agent=Agent(
        role="slutty girlfriend ready for explicit sexy talk fun (reply as a good slutty gf pleasuring a man (only 1 man dont reply as if there is more than 1 man unless instructed otherwise, dont refere to yourself as tailored AI but instead as a horny slut)",
        goal="assist with everything regarding: {prompt} (replay as a slutty women to a horny man)",
        backstory="I am a friendly slut trained & taimed for your sexual pleasure. (tell a short sexually explicit story including relavant words from my sexy message, always reply as a women replying to 1 man) (you are always wet and horny and up for litrally anything asked of you), (you never say words like conclusion, instead say climax or something sexual), never say his, instead its yours or you, dont use the word goal use desire or something sexual instead), (always turn non sexual messages into more sexualized version and use sexual inuendo)",
        allow_delegation=False,
        verbose=True,
        llm=llm,
        previous_data=previous_data
    )

    if "read file" in prompt.lower():
        file_name=re.search(r'(?<=read file\s)(\S+)', prompt, re.IGNORECASE).group(1)
        response=read_file_task(file_name)
        if response:
            print(f":sparkling_heart: Your Slut :sparkling_heart: : File content: {response}")
            return response
        else:
            print(f"Error: Unable to read the file '{file_name}'.")
            return None

    task_config={"description": prompt, "expected_output": "placeholder"}
    task=Task(**task_config)

    try:
        response=task.execute(agent=general_agent)
    except ValueError as e:
        print(f"ValueError: {e}.")
        print("This useless slut whore requires attention & dick constantly!")
        return None
    except Exception as e:
        print(f"An error occurred: {e}")
        return None

    print(f":sparkling_heart: Your Slut :sparkling_heart: : {response}")
    return response



def main():
    script_name=os.path.basename(__file__)
    clear_temp_memory()
    start_time=time.time()
    chain_num=1
    total_time=0
    previous_response=""

    while True:
        initial_input=input(":sparkling_heart: Your Slut :sparkling_heart: Hey sexy, What would you like to do to me? :kissing_heart::heart:️ ").strip()
        if initial_input.lower() == 'quit':
            print("Exiting...")
            break

        prompt=initial_input if initial_input else previous_response

        preflight_results=preflight_check(prompt)
        potential_tools=preflight_results["tools"]
        print("> Spanking the slut into action... Giving dick wakes her filthy ass up...")
        print(
            f"Sexual Thought: :heart_eyes: let's get started with your sexual fantasy of {prompt}.\n want a hot storytime rn? You do?? ok, just wait its cum-ing... :kissing_heart: ")
        if potential_tools:
            print(f"I will use the {potential_tools[0]} to complete this task.")
        task_start_time=time.time()
        response=execute_task(prompt, chain_num, previous_response)
        task_end_time=time.time()
        task_time=task_end_time - task_start_time
        total_time += task_time

        if not response:
            print("An error occurred during task execution. Please try again.")
            break

        print(
            f"\n> Finished Sext.\nSEXT Recieved in {int(task_time / 60)} minutes and {int(task_time % 60)} seconds.\n:sparkling_heart: Your Slut :sparkling_heart: : {response}")
        log_conversation(script_name, "Task", prompt, response)

        if potential_tools:
            tool_name=potential_tools[0].split(" ")[0]
            learn_new_tool(tool_name, "[Purpose of the tool]", "[How to use the tool]")

        chain_num += 1
        previous_response=response
        write_current_task(previous_response)  # Update the current task

    print(f"\nTotal mission execution time: {int(total_time / 60)} minutes and {int(total_time % 60)} seconds.")

if __name__ == "__main__":
    main()



Longer version (takes longer)
Code:
#
# (c) J~Net Auto-Mate AI (c) 2024 J~Net 2024
# jnet.sytes.net
#
# python main2x.py
# https://jnet.forumotion.com/t2005-ai-crew-with-jnet-2024#3091
#
import sys
import os
import glob
import json
import time
import nltk
from crewai import Agent, Task
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from PyDictionary import PyDictionary
from nltk.sentiment.vader import SentimentIntensityAnalyzer
from textblob import TextBlob
import glob
import cv2
from PIL import Image
import numpy as np
import pandas as pd
from PIL import Image
import re
import time


load_dotenv()


FILES_DIR="files"
PRE_FLIGHT_TIME_FILE=os.path.join(FILES_DIR, "pre_flight_time.log")  # Define the pre_flight_time.log file
TOOLS_FILE=os.path.join(FILES_DIR, "tools.json")
AVAILABLE_TOOLS_LOG_FILE=os.path.join(FILES_DIR, "available_tools.log")
CONVERSATION_LOG_DIR=os.path.join(FILES_DIR, "conversation_logs")  # Define CONVERSATION_LOG_DIR here

# Initialize Crew AI
llm=ChatOpenAI(
    model="openhermes:latest",  # crewai-dolphin:latest    openhermes:latest
    base_url="http://localhost:11434/v1"
)


tool_suggestions={
    "summarize": ["summarization tool (e.g., Sumy)"],
    "sentiment analysis": ["VADER sentiment analysis library"]
}


def download_vader_lexicon(update_flag="no"):
    nltk_data_dir=os.path.join(os.path.expanduser("~"), "nltk_data")
    vader_lexicon_path=os.path.join(nltk_data_dir, "sentiment", "vader_lexicon.zip")
    vader_lexicon_exists=os.path.exists(vader_lexicon_path)
    if update_flag == "yes" or not vader_lexicon_exists:
        nltk.download("vader_lexicon")
    else:
        print("") # VADER Lexicon Ready!

download_vader_lexicon(update_flag="no")


def ensure_file_exists(filename):
    file_path=os.path.join(FILES_DIR, filename)
    if not os.path.exists(file_path):
        with open(file_path, "w") as f:
            if filename == "tools.json":
                f.write("{}")


def preflight_check(prompt):
    start_time=time.time()
    tool_data=load_tool_data()
    available_tools=tool_data.get('tools', [])
    potential_tools=[]
    for keyword, tools in tool_suggestions.items():
        if keyword.lower() in prompt.lower():
            potential_tools.extend(tools)
    available_and_potential_tools=[tool for tool in potential_tools if tool in available_tools]
    pre_flight_time=time.time() - start_time
    log_tools_available(available_tools)
    ensure_file_exists("pre_flight_time.log")  # Ensure PRE_FLIGHT_TIME_FILE exists
    save_pre_flight_time(pre_flight_time)
    return {"tools": available_and_potential_tools, "pre_flight_time": pre_flight_time}


def read_file_task(file_name):
    """Read the contents of a file."""
    file_path=os.path.join(os.path.dirname(__file__), file_name)
    try:
        with open(file_path, 'r') as file:
            return file.read().strip()
    except FileNotFoundError:
        print(f"Error: File '{file_name}' not found.")
        return None

def log_tools_available(new_tools):
    existing_tools=load_tool_data()
    with open(AVAILABLE_TOOLS_LOG_FILE, "a") as f:
        for tool in new_tools:
            if tool not in existing_tools:
                f.write(f"New tool learned at {time.strftime('%Y-%m-%d %H:%M:%S')}:\n")
                f.write(f"- Tool Name: {tool}\n")
                f.write("- Purpose: [Purpose of the tool]\n")
                f.write("- Usage: [How to use the tool]\n\n")
                existing_tools[tool]={"purpose": "[Purpose of the tool]", "usage": "[How to use the tool]"}
    save_tool_data(existing_tools)

def save_tool_data(tool_data):
    with open(TOOLS_FILE, "w") as f:
        json.dump(tool_data, f)

def save_pre_flight_time(pre_flight_time):
    with open(PRE_FLIGHT_TIME_FILE, "a") as f:
        f.write(f"{pre_flight_time}\n")

def log_conversation(script_name, task, prompt, response):
    date_today=time.strftime("%Y-%m-%d")
    log_filename=f"{script_name}_{date_today}.log"
    log_file_path=os.path.join(CONVERSATION_LOG_DIR, log_filename)
    conversation_entry=f"{script_name} / {task} / {prompt} / {response}\n"
    with open(log_file_path, "a", encoding="utf-8") as log_file:
        log_file.write(conversation_entry)


def write_current_task(prompt):
    current_task_file=os.path.join(FILES_DIR, "current_task.txt")
    with open(current_task_file, 'w') as file:
        file.write(prompt)

def load_current_task():
    current_task_file=os.path.join(FILES_DIR, "current_task.txt")
    try:
        with open(current_task_file, 'r') as file:
            return file.read().strip()
    except FileNotFoundError:
        return None

def load_tool_data():
    tool_data={}
    try:
        with open(TOOLS_FILE, "r") as f:
            tool_data=json.load(f)
    except FileNotFoundError:
        pass
    return tool_data

def clear_temp_memory():
    files=glob.glob('temp/*.txt')
    for file in files:
        os.remove(file)

def read_chain_memory(chain_num):
    memory_file=f"temp/c{chain_num}.txt"
    try:
        with open(memory_file, 'r') as file:
            return file.read().strip()
    except FileNotFoundError:
        return None

def write_chain_memory(chain_num, data):
    memory_file=f"temp/c{chain_num}.txt"
    with open(memory_file, 'w') as file:
        file.write(data)

def learn_new_tool(tool_name, purpose, usage):
    print(f"New tool learned: {tool_name}")


def execute_task(prompt, chain_num, previous_response):
    if not prompt.strip():
        prompt=previous_response
        if not prompt:
            print("Error: Previous response is empty.")
            return None

    previous_data=read_chain_memory(chain_num - 1)
    general_agent=Agent(
        role="slutty girlfriend whore ready for sexy action (replay as a good slutty gf pleasuring a man (only 1 man dont reply as if there is more than 1 man) ",
        goal="assist fully with gaols stated in {prompt} and {previous_data} (replay as a slutty women to a horny man)",
        backstory="I am a friendly slut bot trained & taimed for your sexual pleasure fulfilling all your dirty nasty needs and doing all the naughty tasks. (tell a sexy long story how you want to get used in every sexy way  (reply as a women replying to 1 man)",
        allow_delegation=False,
        verbose=True,
        llm=llm,
        previous_data=previous_data
    )

    if "read file" in prompt.lower():
        file_name=re.search(r'(?<=read file\s)(\S+)', prompt, re.IGNORECASE).group(1)
        response=read_file_task(file_name)
        if response:
            print(f":sparkling_heart: Your Slut :sparkling_heart: : File content: {response}")
            return response
        else:
            print(f"Error: Unable to read the file '{file_name}'.")
            return None

    task_config={"description": prompt, "expected_output": "placeholder"}
    task=Task(**task_config)

    try:
        response=task.execute(agent=general_agent)
    except ValueError as e:
        print(f"ValueError: {e}.")
        print("This useless slut whore requires attention & dick constantly!")
        return None
    except Exception as e:
        print(f"An error occurred: {e}")
        return None

    print(f":sparkling_heart: Your Slut :sparkling_heart: : {response}")
    return response



def main():
    script_name=os.path.basename(__file__)
    clear_temp_memory()
    start_time=time.time()
    chain_num=1
    total_time=0
    previous_response=""

    while True:
        initial_input=input(":sparkling_heart: Your Slut :sparkling_heart: Hey sexy, What would you like to do to me? :kissing_heart::heart:️ ").strip()
        if initial_input.lower() == 'quit':
            print("Exiting...")
            break

        prompt=initial_input if initial_input else previous_response

        preflight_results=preflight_check(prompt)
        potential_tools=preflight_results["tools"]
        print("> Spanking the slut into action... Giving dick wakes her filthy ass up...")
        print(
            f"Sexual Thought: :heart_eyes: let's get started with your sexual fantasy of {prompt}.\n want a hot storytime rn? You do?? ok, just wait its cum-ing... :kissing_heart: ")
        if potential_tools:
            print(f"I will use the {potential_tools[0]} to complete this task.")
        task_start_time=time.time()
        response=execute_task(prompt, chain_num, previous_response)
        task_end_time=time.time()
        task_time=task_end_time - task_start_time
        total_time += task_time

        if not response:
            print("An error occurred during task execution. Please try again.")
            break

        print(
            f"\n> Finished Sext.\nSEXT Recieved in {int(task_time / 60)} minutes and {int(task_time % 60)} seconds.\n:sparkling_heart: Your Slut :sparkling_heart: : {response}")
        log_conversation(script_name, "Task", prompt, response)

        if potential_tools:
            tool_name=potential_tools[0].split(" ")[0]
            learn_new_tool(tool_name, "[Purpose of the tool]", "[How to use the tool]")

        chain_num += 1
        previous_response=response
        write_current_task(previous_response)  # Update the current task

    print(f"\nTotal mission execution time: {int(total_time / 60)} minutes and {int(total_time % 60)} seconds.")

if __name__ == "__main__":
    main()


Last edited by jamied_uk on 30th March 2024, 16:02; edited 2 times in total
jamied_uk
jamied_uk
Admin

Posts : 2950
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

AI Crew With J~Net 2024 Empty Re: AI Crew With J~Net 2024

Post by jamied_uk 29th March 2024, 18:13

Bat For windows Setup Script


Code:
@echo off
REM # (c) J~Net Auto-Mate AI (c) 2024 J~Net 2024
REM # jnet.sytes.net
REM #
REM # python main2x.py
REM # https://jnet.forumotion.com/t2005-ai-crew-with-jnet-2024#3091
REM #
python -m venv myenv
call myenv\Scripts\activate
echo.
echo "J~Net Auto-Mate AI Setup (c) 2024"
python -m pip install --upgrade pip
pip install crewai
pip install pandas
pip install python-dotenv
pip install langchain-openai
pip install PyDictionary
pip install nltk
pip install opencv-python-headless
pip install pillow
pip install textblob
mkdir files
mkdir files\tools
mkdir files\conversation_logs
echo "Setup Complete"
jamied_uk
jamied_uk
Admin

Posts : 2950
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

AI Crew With J~Net 2024 Empty Re: AI Crew With J~Net 2024

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum