You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
854 B
38 lines
854 B
import os |
|
import base64 |
|
from ollama import Client, ChatResponse |
|
import env_manager |
|
from colorprinter.print_color import * |
|
import httpx |
|
|
|
env_manager.set_env() |
|
|
|
# Encode the credentials |
|
auth = httpx.BasicAuth( |
|
username='lasse', password=os.getenv("LLM_API_PWD_LASSE") |
|
) |
|
client = httpx.Client(auth=auth) |
|
client = Client( |
|
host="http://localhost:11434", |
|
headers={ |
|
"X-Chosen-Backend": "backend_ollama" # Add this header to specify the chosen backend |
|
}, |
|
auth=auth |
|
) |
|
response = client.chat( |
|
model=os.getenv("LLM_MODEL"), |
|
messages=[ |
|
{ |
|
"role": "user", |
|
"content": "Why is the sky blue?", |
|
}, |
|
], |
|
) |
|
|
|
# Print the response headers |
|
|
|
# Print the chosen backend from the headers |
|
print("Chosen Backend:", response.headers.get("X-Chosen-Backend")) |
|
|
|
# Print the response content |
|
print(response) |