commit 4b0091599bd013e71fdcf32f3a17eee128e789f8 Author: matt Date: Sat Sep 7 21:57:22 2024 +0200 Initial commit. This script lets 2 LLMs on my local machine talk to each other. diff --git a/bash-llama.sh b/bash-llama.sh new file mode 100755 index 0000000..4db6224 --- /dev/null +++ b/bash-llama.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Replace with your actual connection details +server_one_url="http://localhost:11434" +server_two_url="http://localhost:11435" +model="llama3" + +read -p "Kick things off with a question: " input + +oneResponse=$(curl -s -X POST "$server_one_url/api/chat" \ + -d "{\"model\": \"$model\",\ + \"messages\": [ + { + \"role\": \"user\", + \"content\": \"$input\" + } \ + ],\ + \"stream\": false }" | jq -r .message.content | tr -d '[\n]') +printf "LLM One: $oneResponse\n" + +while true; do + + twoResponse=$(curl -s -X POST "http://localhost:11435/api/chat" \ + -d "{\"model\": \"$model\",\ + \"messages\": [ + { + \"role\": \"user\", + \"content\": \"$oneResponse\" + } \ + ],\ + \"stream\": false }" | jq -r .message.content | tr -d '[\n]') + printf "LLM Two: $twoResponse\n" + + oneResponse=$(curl -s -X POST "http://localhost:11434/api/chat" \ + -d "{\"model\": \"$model\",\ + \"messages\": [ + { + \"role\": \"user\", + \"content\": \"$twoResponse\" + } \ + ],\ + \"stream\": false }" | jq -r .message.content | tr -d '[\n]') + printf "LLM One: $oneResponse\n" + +done