by Fus3n
A simple experiment on letting two local LLM have a conversation about anything!
# Add to your Claude Code skills
git clone https://github.com/Fus3n/TwoAIA simple experiment on letting two local LLM have a conversation about anything!
If you want to discuss more join the discord!
<img src="images/demo-1.png"/>First you need Ollama, install the executable as per the instructions. After that just make sure ollama is running in background, check your system tray. then find the model you like https://ollama.com/library and just do:
ollama pull <model-name>
The installation commands are usually in the library page.
Example in src/example/main.py
If you are using pdm you can install the package as with pdm install
git clone https://github.com/Fus3n/TwoAI
cd TwoAI
pip install -r requirements.txt
python src/example/main.py llama3
# with pdm
pdm run example llama3
# Setup
BASE_MODEL = "llama3" # need to be pulled first if you want to use this, `ollama pull llama3`
sys_prompt = """
You are a very intelligent AI Chatbot and your name is {current_name}, Now
you will be having a converstaion with another AI called {other_name}, and its also same as you.
{current_objective} Keep each message short and concise and repeat "<DONE!>" ONLY if you both established and agreed that you came to the end of the discussion.
""".strip()
agent_details: AgentDetails = (
{
"name": "Zerkus",
"objective": "Debate against the other AI on what came first, the chicken or the egg."
"and you think the chicken came first."
"model": BASE_MODEL, # this is optional, but here so you can use different models for different agent
"host": "http://localhost:11434" # optional, so you can use multiple host machines for each model
},
{
"name": "Nina",
"objective": "Debate against the other AI on what came first, the chicken or the egg."
"and you think the Egg came first."
}
)
twoai = TWOAI(
model=BASE_MODEL,
agent_details=agent_details,
system_prompt=sys_prompt
exit_word="<DONE!>",
max_exit_words=2,
)
Now to get response there are two ways
twoai.next_response(show_output=True)
twoai.next_response(show_output=True)
twoai.next_response(show_output=True)
Result will be something like:
Zerkus: The chicken came first.
Nina: The egg came first.
Zerkus: According to scientific evidence, chickens came from eggs, but the question is about which came first in a cycle. Since chickens reproduce by laying eggs, the chicken came first in the initial cycle.
Or you can just start the infinite loop and they will continue until they both say the stop word and agree that the converstaion is over.
twoai.start_conversation()
The above conversation is from the data the...