diff --git a/README.md b/README.md index d059703..bd59dd4 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ pip install funcchain ## Introduction `funcchain` is the *most pythonic* way of writing cognitive systems. Leveraging pydantic models as output schemas combined with langchain in the backend allows for a seamless integration of llms into your apps. -It utilizes perfect with OpenAI Functions or LlamaCpp grammars (json-schema-mode) for efficient structured output. +It utilizes OpenAI Functions or LlamaCpp grammars (json-schema-mode) for efficient structured output. In the backend it compiles the funcchain syntax into langchain runnables so you can easily invoke, stream or batch process your pipelines. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/ricklamers/funcchain-demo) @@ -112,7 +112,7 @@ class AnalysisResult(BaseModel): objects: list[str] = Field(description="A list of objects found in the image") # easy use of images as input with structured output -def analyse_image(image: Image.Image) -> AnalysisResult: +def analyse_image(image: Image) -> AnalysisResult: """ Analyse the image and extract its theme, description and objects. diff --git a/src/funcchain/backend/settings.py b/src/funcchain/backend/settings.py index 645203f..8820c86 100644 --- a/src/funcchain/backend/settings.py +++ b/src/funcchain/backend/settings.py @@ -27,11 +27,12 @@ class FuncchainSettings(BaseSettings): retry_parse: int = 3 retry_parse_sleep: float = 0.1 - # KEYS + # KEYS / URLS openai_api_key: Optional[str] = None azure_api_key: Optional[str] = None anthropic_api_key: Optional[str] = None google_api_key: Optional[str] = None + ollama_base_url: str = "http://localhost:11434" # MODEL KWARGS verbose: bool = False @@ -60,7 +61,9 @@ def openai_kwargs(self) -> dict: } def ollama_kwargs(self) -> dict: - return {} + return { + "base_url": self.ollama_base_url + } def llamacpp_kwargs(self) -> dict: return { diff --git a/src/funcchain/model/defaults.py b/src/funcchain/model/defaults.py index 046d593..cc8aef5 100644 --- a/src/funcchain/model/defaults.py +++ b/src/funcchain/model/defaults.py @@ -155,7 +155,7 @@ def univeral_model_selector( except Exception as e: print(e) - model_kwargs.pop("model_name") + model_kwargs.pop("model_name", None) if settings.openai_api_key: from langchain_openai.chat_models import ChatOpenAI diff --git a/src/funcchain/syntax/executable.py b/src/funcchain/syntax/executable.py index 4bab684..b95dbf3 100644 --- a/src/funcchain/syntax/executable.py +++ b/src/funcchain/syntax/executable.py @@ -42,6 +42,8 @@ def chain( # todo maybe this should be done in the prompt processor? system = system or settings.system_prompt + if system: + context = [SystemMessage(content=system)] + context instruction = instruction or from_docstring() # temp image handling @@ -90,6 +92,8 @@ async def achain( # todo maybe this should be done in the prompt processor? system = system or settings.system_prompt + if system: + context = [SystemMessage(content=system)] + context instruction = instruction or from_docstring() # temp image handling