Initial commit. This script lets 2 LLMs on my local machine talk to each other.

This commit is contained in:
2024-09-07 21:57:22 +02:00
commit 4b0091599b

45
bash-llama.sh Executable file
View File

@@ -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