22 lines
646 B
Python
22 lines
646 B
Python
|
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.")
|