From 7e0d4552c38a5b76febcfb5f4df72c1cd45c6206 Mon Sep 17 00:00:00 2001 From: Piero Savastano Date: Fri, 11 Aug 2023 18:15:39 +0200 Subject: [PATCH 1/5] Update ROADMAP.md --- readme/ROADMAP.md | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/readme/ROADMAP.md b/readme/ROADMAP.md index fae485d6..b679c8f1 100644 --- a/readme/ROADMAP.md +++ b/readme/ROADMAP.md @@ -1,50 +1,47 @@ * Version 1 - * Forms from JSON schema ✅ + * Forms from JSON schema ✅ * Configurations - * Language model provider ✅ - * Embedder - * Plugins list ✅ - * Why in the admin ✅ - * Documentation ✅ - * Markdown support ✅ - * Static admin inside main container ✅ + * Language model provider ✅ + * Embedder ✅ + * Plugins list ✅ + * Why in the admin ✅ + * Documentation ✅ + * Markdown support ✅ + * Static admin inside main container ✅ * [Public `/chat` endpoint](https://github.com/cheshire-cat-ai/core/issues/267/) ✅ * [js widget (for `/chat` and external websites)](https://github.com/cheshire-cat-ai/core/issues/269/) ✅ * Memory management page in admin ✅ - -
- -* Version 2 * User management - * User specific conversation and memory + * User specific conversation and memory ✅ * Dissemination * minimal website ✅ - * how to guides + * how to guides ✅ * use cases examples * QA / Test * End2End tests * Setup ✅ - * Essential coverage - * Unit tests - * Setup - * Essential coverage + * Essential coverage ✅ + * Unit tests + * Setup ✅ + * Essential coverage ✅ * Admin - * import memories + * import memories ✅ * export memeories ✅ * filters for memory search - * better `why` UI + * better `why` UI ✅ * Agent * Tool embeddings ✅ * Custom hookable agent * Local LLM / embedder - * CustomLLMConfig / CustomEmbedderConfig adapters + * CustomLLMConfig + * CustomEmbedderConfig adapters * LLM / embedder example docker container * Hook surface * 20 hooks ✅ * more hooks where customization is needed * Plugin management * Install plugin dependencies ✅ - * Activate / deactivate plugins - * External plugin directory + * Activate / deactivate plugins ✅ + * External plugin directory ✅ * Pugin manifesto (`plugin.json`) ✅ From fd80b5efa8ae4fd330c7ac931dccff46b2fb72e6 Mon Sep 17 00:00:00 2001 From: Nicorb <67009524+nicola-corbellini@users.noreply.github.com> Date: Tue, 15 Aug 2023 14:29:09 +0200 Subject: [PATCH 2/5] Update README.md --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 647ddb9b..e7a9a280 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,22 @@

Cheshire-Cat (Stregatto)

+
+ + GitHub Repo stars + + + chat on Discord + + GitHub issues + + + GitHub tag (with filter) + + GitHub top language + +
Logo

Customizable AI architecture From 89125b21d31e986287f69ac5bf8b101af7c633c1 Mon Sep 17 00:00:00 2001 From: Nicola Date: Thu, 17 Aug 2023 18:07:42 +0200 Subject: [PATCH 3/5] fix bug in `get_llm_from_config` for `LLMCustomConfig` --- core/cat/factory/llm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cat/factory/llm.py b/core/cat/factory/llm.py index 7cfd70dd..6a0b2564 100644 --- a/core/cat/factory/llm.py +++ b/core/cat/factory/llm.py @@ -46,7 +46,7 @@ class LLMCustomConfig(LLMSettings): @classmethod def get_llm_from_config(cls, config): # options are inserted as a string in the admin - if type(config["options"]) == str: + if isinstance(config["options"], dict): config["options"] = json.loads(config["options"]) return cls._pyclass(**config) From 934584d0fe2ec43fda992d9639d6f1084b3a6b57 Mon Sep 17 00:00:00 2001 From: Nicola Date: Fri, 18 Aug 2023 10:11:38 +0200 Subject: [PATCH 4/5] add header to `request.post` --- core/cat/factory/custom_llm.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/core/cat/factory/custom_llm.py b/core/cat/factory/custom_llm.py index 092ecebe..d3b07c6d 100644 --- a/core/cat/factory/custom_llm.py +++ b/core/cat/factory/custom_llm.py @@ -1,6 +1,7 @@ from typing import Optional, List, Any, Mapping, Dict import requests from langchain.llms.base import LLM +from cat.log import log class LLMDefault(LLM): @@ -10,13 +11,12 @@ def _llm_type(self): def _call(self, prompt, stop=None): return "AI: You did not configure a Language Model. " \ - "Do it in the settings!" + "Do it in the settings!" # elaborated from # https://python.langchain.com/en/latest/modules/models/llms/examples/custom_llm.html class LLMCustom(LLM): - # endpoint where custom LLM service accepts requests url: str @@ -31,11 +31,11 @@ def _llm_type(self) -> str: return "custom" def _call( - self, - prompt: str, - stop: Optional[List[str]] = None, - # run_manager: Optional[CallbackManagerForLLMRun] = None, - run_manager: Optional[Any] = None, + self, + prompt: str, + stop: Optional[List[str]] = None, + # run_manager: Optional[CallbackManagerForLLMRun] = None, + run_manager: Optional[Any] = None, ) -> str: request_body = { @@ -44,11 +44,16 @@ def _call( "options": self.options } + headers = { + 'accept': 'application/json', + 'Content-Type': 'application/json' + } + try: - response_json = requests.post(self.url, json=request_body).json() - except Exception: - raise Exception("Custom LLM endpoint error " - "during http POST request") + response_json = requests.post(self.url, json=request_body, headers=headers).json() + except Exception as exc: + raise ValueError("Custom LLM endpoint error " + "during http POST request") from exc generated_text = response_json["text"] From 2577acf6ddbd7f49437aca86d026ec32e13318ed Mon Sep 17 00:00:00 2001 From: Nicola Date: Fri, 18 Aug 2023 12:18:15 +0200 Subject: [PATCH 5/5] restored type check to string --- core/cat/factory/custom_llm.py | 2 +- core/cat/factory/llm.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/cat/factory/custom_llm.py b/core/cat/factory/custom_llm.py index d3b07c6d..73b99d1a 100644 --- a/core/cat/factory/custom_llm.py +++ b/core/cat/factory/custom_llm.py @@ -50,7 +50,7 @@ def _call( } try: - response_json = requests.post(self.url, json=request_body, headers=headers).json() + response_json = requests.post(self.url, json=request_body).json() except Exception as exc: raise ValueError("Custom LLM endpoint error " "during http POST request") from exc diff --git a/core/cat/factory/llm.py b/core/cat/factory/llm.py index 6a0b2564..92a1d715 100644 --- a/core/cat/factory/llm.py +++ b/core/cat/factory/llm.py @@ -36,7 +36,6 @@ class Config: class LLMCustomConfig(LLMSettings): - url: str auth_key: str = "optional_auth_key" options: str = "{}" @@ -45,16 +44,20 @@ class LLMCustomConfig(LLMSettings): # instantiate Custom LLM from configuration @classmethod def get_llm_from_config(cls, config): + options = config["options"] # options are inserted as a string in the admin - if isinstance(config["options"], dict): - config["options"] = json.loads(config["options"]) + if isinstance(options, str): + if options != "": + config["options"] = json.loads(options) + else: + config["options"] = {} return cls._pyclass(**config) class Config: schema_extra = { "humanReadableName": "Custom LLM", - "description": + "description": "LLM on a custom endpoint. " "See docs for examples.", } @@ -80,7 +83,7 @@ class LLMOpenAIConfig(LLMSettings): class Config: schema_extra = { "humanReadableName": "OpenAI GPT-3", - "description": + "description": "OpenAI GPT-3. More expensive but " "also more flexible than ChatGPT.", } @@ -138,6 +141,7 @@ class Config: "description": "Configuration for Cohere language model", } + # https://python.langchain.com/en/latest/modules/models/llms/integrations/huggingface_textgen_inference.html class LLMHuggingFaceTextGenInferenceConfig(LLMSettings): inference_server_url: str @@ -155,6 +159,7 @@ class Config: "description": "Configuration for HuggingFace TextGen Inference", } + class LLMHuggingFaceHubConfig(LLMSettings): # model_kwargs = { # "generation_config": {