Skip to content

Commit

Permalink
urllib to join ollama url domain to endpoint in place of string format
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieran-Sears committed Nov 12, 2024
1 parent 59a46d0 commit b3980e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion goldenverba/components/embedding/OllamaEmbedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import requests
from wasabi import msg
import aiohttp
from urllib.parse import urljoin

from goldenverba.components.interfaces import Embedding
from goldenverba.components.types import InputConfig
Expand Down Expand Up @@ -33,7 +34,8 @@ async def vectorize(self, config: dict, content: list[str]) -> list[float]:
data = {"model": model, "input": content}

async with aiohttp.ClientSession() as session:
async with session.post(self.url + "/api/embed", json=data) as response:
url = urljoin(self.url, "/api/embed")
async with session.post(url, json=data) as response:
response.raise_for_status()
data = await response.json()
embeddings = data.get("embeddings", [])
Expand Down
4 changes: 3 additions & 1 deletion goldenverba/components/generation/OllamaGenerator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import json
import aiohttp
from urllib.parse import urljoin
from typing import List, Dict, AsyncGenerator

from goldenverba.components.interfaces import Generator
Expand Down Expand Up @@ -35,7 +36,8 @@ async def generate_stream(
conversation: List[Dict] = [],
) -> AsyncGenerator[Dict, None]:
model = config.get("Model").value
url = f"{self.url}/api/chat"

url = urljoin(self.url, "/api/chat")
system_message = config.get("System Message").value

if not self.url:
Expand Down

0 comments on commit b3980e4

Please sign in to comment.