module updates
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from typing import Any, Dict
|
||||
from ollama import Client
|
||||
from langchain_core.runnables.base import Runnable
|
||||
from langchain.prompts.base import StringPromptValue
|
||||
|
||||
class OllamaWrapper(Runnable):
|
||||
def __init__(self, host: str, model: str = "llama3.2:latest"):
|
||||
@@ -9,8 +8,11 @@ class OllamaWrapper(Runnable):
|
||||
self.model = model
|
||||
|
||||
def invoke(self, prompt: Any, config: Dict[str, Any] = None, **kwargs: Any) -> str:
|
||||
if isinstance(prompt, StringPromptValue):
|
||||
# Handle different prompt types (StringPromptValue, str, etc.)
|
||||
if hasattr(prompt, 'to_string'):
|
||||
prompt = prompt.to_string()
|
||||
elif not isinstance(prompt, str):
|
||||
prompt = str(prompt)
|
||||
|
||||
# Use the model from constructor, but allow override via kwargs
|
||||
model_name = kwargs.get("model", self.model)
|
||||
|
||||
Reference in New Issue
Block a user