From 66a88e6ac3f646b2af0fd32e766446ecf81250f6 Mon Sep 17 00:00:00 2001 From: Jeffrey Quesnelle Date: Fri, 9 Feb 2024 14:46:39 -0500 Subject: [PATCH 1/5] add `ollama_base_url` setting --- src/funcchain/backend/settings.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/funcchain/backend/settings.py b/src/funcchain/backend/settings.py index 377af66..b9f8b73 100644 --- a/src/funcchain/backend/settings.py +++ b/src/funcchain/backend/settings.py @@ -25,11 +25,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 @@ -58,7 +59,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 { From cb229ca3a21a32a6186209067a09761bd41a151c Mon Sep 17 00:00:00 2001 From: Andrew Huang Date: Fri, 9 Feb 2024 11:47:04 -0800 Subject: [PATCH 2/5] Add system prompt to chain --- src/funcchain/syntax/executable.py | 4 ++++ 1 file changed, 4 insertions(+) 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 From 860f8856cf7e11740ec2191934cfc4bd3e2d28cc Mon Sep 17 00:00:00 2001 From: Andrew <15331990+ahuang11@users.noreply.github.com> Date: Fri, 9 Feb 2024 17:20:17 -0800 Subject: [PATCH 3/5] Fix pop model_name --- src/funcchain/model/defaults.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 8afe8db0f68531fb689919a8b0ff18bae5420223 Mon Sep 17 00:00:00 2001 From: shroominic <34897716+shroominic@users.noreply.github.com> Date: Sun, 11 Feb 2024 16:25:45 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=93=9Dfix=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d059703..04cd93d 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) From 19bc8963c706a001613629e7bbca2610413117fe Mon Sep 17 00:00:00 2001 From: shroominic <34897716+shroominic@users.noreply.github.com> Date: Sun, 11 Feb 2024 16:37:44 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=93=9D=20fix=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04cd93d..bd59dd4 100644 --- a/README.md +++ b/README.md @@ -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.