ig_bot/unsorted/ollamatest.py

22 lines
646 B
Python
Raw Normal View History

2024-05-25 09:13:33 +02:00
import httpx
from ollama import Client
# Initialize the ollama client
# Replace 'http://localhost:11434' with the actual address of your ollama server if different
ollama_client = Client(host='http://localhost:11434')
def test_ollama(prompt: str):
try:
response = ollama_client.chat(model="mixtral", messages=[{"role": "user", "content": prompt}])
if response:
print("Received response from ollama:")
print(response)
else:
print("No response from ollama.")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
test_ollama("Hello.")