From 4b0091599bd013e71fdcf32f3a17eee128e789f8 Mon Sep 17 00:00:00 2001 From: matt Date: Sat, 7 Sep 2024 21:57:22 +0200 Subject: [PATCH] Initial commit. This script lets 2 LLMs on my local machine talk to each other. --- bash-llama.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 bash-llama.sh 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