Quantcast
Channel: Weaviate Community Forum - Latest posts
Viewing all articles
Browse latest Browse all 3588

Ollama Embeddings call fails with wrong URL path: /api/embeddings

$
0
0

super weird but when I take the example you have above and edit it to use client = weaviate.connect_to_custom it still fails.

The script is being ran from my local PC. Weaviate and Ollama are running on a server called “mothership” and connectivity works otherwise.

EDITED SCRIPT:

import weaviate
from weaviate import classes as wvc
import os
from weaviate.classes.init import AdditionalConfig, Timeout
from weaviate.classes.config import Property, DataType
from dotenv import load_dotenv
load_dotenv()

WEAVIATE_HOST = os.getenv("WEAVIATE_HOST")
WEAVIATE_PORT = os.getenv("WEAVIATE_PORT")
EMBEDDING_MODEL = os.getenv("EMBEDDING_MODEL")
OLLAMA_HOST = os.getenv("OLLAMA_HOST")

client = weaviate.connect_to_custom(
    http_host=WEAVIATE_HOST,
    http_port=WEAVIATE_PORT,
    http_secure=False,
    grpc_host=WEAVIATE_HOST,
    grpc_port=50051,
    grpc_secure=False,
    skip_init_checks=True,
    additional_config=AdditionalConfig(
        timeout=Timeout(init=10, query=20, insert=120)  # Values in seconds
    )
)

print(f"Client: {weaviate.__version__}, Server: client.get_meta().get('version')")

client.collections.delete("Test")
collection = client.collections.create(
        name="Test",
        vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_ollama(
            api_endpoint="http://mothership:11434",
            model="snowflake-arctic-embed"
        ),
        generative_config=wvc.config.Configure.Generative.ollama(
            api_endpoint="http://mothership:11434",  
            model="llama3.1"
        )
    )
collection.data.insert({"text": "Why is the sky blue?"})
print(len(collection.query.fetch_objects(include_vector=True).objects[0].vector.get("default")))
print(collection.generate.fetch_objects(single_prompt="answer: {text}").objects[0].generated)
client.close()

ERROR:

python test.py
Client: 4.9.3, Server: client.get_meta().get('version')
Traceback (most recent call last):
  File "/home/razor/repos/assistant/test.py", line 41, in <module>
    collection.data.insert({"text": "Why is the sky blue?"})
  File "/home/razor/repos/assistant/.venvrag/lib/python3.10/site-packages/weaviate/syncify.py", line 23, in sync_method
    return _EventLoopSingleton.get_instance().run_until_complete(
  File "/home/razor/repos/assistant/.venvrag/lib/python3.10/site-packages/weaviate/event_loop.py", line 42, in run_until_complete
    return fut.result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/home/razor/repos/assistant/.venvrag/lib/python3.10/site-packages/weaviate/collections/data/data.py", line 340, in insert
    return await self._insert(weaviate_obj)
  File "/home/razor/repos/assistant/.venvrag/lib/python3.10/site-packages/weaviate/collections/data/data.py", line 84, in _insert
    await self._connection.post(
  File "/home/razor/repos/assistant/.venvrag/lib/python3.10/site-packages/weaviate/connect/v4.py", line 525, in post
    return await self.__send(
  File "/home/razor/repos/assistant/.venvrag/lib/python3.10/site-packages/weaviate/connect/v4.py", line 480, in __send
    raise e
  File "/home/razor/repos/assistant/.venvrag/lib/python3.10/site-packages/weaviate/connect/v4.py", line 471, in __send
    raise UnexpectedStatusCodeError(error_msg, response=res)
weaviate.exceptions.UnexpectedStatusCodeError: Object was not added! Unexpected status code: 500, with response body: {'error': [{'message': 'update vector: send POST request: Post "http://mothership:11434/api/embeddings": dial tcp 127.0.1.1:11434: connect: connection refused'}]}.
/home/razor/repos/assistant/.venvrag/lib/python3.10/site-packages/weaviate/warnings.py:329: ResourceWarning: Con004: The connection to Weaviate was not closed properly. This can lead to memory leaks.
            Please make sure to close the connection using `client.close()`.
/usr/lib/python3.10/asyncio/selector_events.py:710: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=6 read=idle write=<idle, bufsize=0>>

Viewing all articles
Browse latest Browse all 3588

Trending Articles