mirror of
https://github.com/ollama/ollama-python.git
synced 2026-06-06 00:04:47 +00:00
add embeddings
This commit is contained in:
@@ -21,6 +21,7 @@ __all__ = [
|
||||
'ResponseError',
|
||||
'generate',
|
||||
'chat',
|
||||
'embeddings',
|
||||
'pull',
|
||||
'push',
|
||||
'create',
|
||||
@@ -34,6 +35,7 @@ _client = Client()
|
||||
|
||||
generate = _client.generate
|
||||
chat = _client.chat
|
||||
embeddings = _client.embeddings
|
||||
pull = _client.pull
|
||||
push = _client.push
|
||||
create = _client.create
|
||||
|
||||
@@ -170,6 +170,17 @@ class Client(BaseClient):
|
||||
stream=stream,
|
||||
)
|
||||
|
||||
def embeddings(self, model: str = '', prompt: str = '', options: Optional[Options] = None) -> Sequence[float]:
|
||||
return self._request(
|
||||
'POST',
|
||||
'/api/embeddings',
|
||||
json={
|
||||
'model': model,
|
||||
'prompt': prompt,
|
||||
'options': options or {},
|
||||
},
|
||||
).json()
|
||||
|
||||
def pull(
|
||||
self,
|
||||
model: str,
|
||||
@@ -425,6 +436,19 @@ class AsyncClient(BaseClient):
|
||||
stream=stream,
|
||||
)
|
||||
|
||||
async def embeddings(self, model: str = '', prompt: str = '', options: Optional[Options] = None) -> Sequence[float]:
|
||||
response = await self._request(
|
||||
'POST',
|
||||
'/api/embeddings',
|
||||
json={
|
||||
'model': model,
|
||||
'prompt': prompt,
|
||||
'options': options or {},
|
||||
},
|
||||
)
|
||||
|
||||
return response.json()
|
||||
|
||||
async def pull(
|
||||
self,
|
||||
model: str,
|
||||
|
||||
Reference in New Issue
Block a user