Commit Graph

320 Commits

Author SHA1 Message Date
Tuan Anh Nguyen Dang (Tadashi_Cin)
f9fc02a32a [AUR-363, AUR-433, AUR-434] Add Base Tool interface with Wikipedia/Google tools (#30)
* add base Tool

* minor update test_tool

* update test dependency

* update test dependency

* Fix namespace conflict

* update test

---------

Co-authored-by: trducng <trungduc1992@gmail.com>
2023-09-29 10:18:49 +07:00
cin-jacky
317323c0e5 [AUR-424] Setup CLI interface (#25)
* [AUR-424] Setup CLI interface

* [AUR-424] fix test_vectorstore:test_query

* [AUR-424] exclude examples when setup CLI

* [AUR-424] create kh and kh --export

* [AUR-426] revise cli by using click.group

* Fix dynamic import

* [AUR-426] revert the format of import packages

* [AUR-426] set argument default

* [AUR-426] set click dependencies in setup.py

---------

Co-authored-by: trducng <trungduc1992@gmail.com>
2023-09-27 16:44:38 +09:00
Tuan Anh Nguyen Dang (Tadashi_Cin)
6c3d614973 [AUR-432] Add layout-aware table parsing PDF reader (#27)
* add OCRReader, MathPixReader and ExcelReader

* update test case for ocr reader

* reformat

* minor fix
2023-09-26 15:52:44 +07:00
Tuan Anh Nguyen Dang (Tadashi_Cin)
6207f4332a [AUR-430] Add test case for Chroma VectoStore save/load (#26)
* add test case for Chroma save/load

* minor name change

* add delete_collection support for chroma

* move save load to chroma

---------

Co-authored-by: Nguyen Trung Duc (john) <john@cinnamon.is>
2023-09-26 10:58:41 +07:00
Nguyen Trung Duc (john)
4f189dc931 [AUR-408] Export logs to Excel (#23)
This CL implements:

- The logic to export log to Excel.
- Route the export logic in the UI.
- Demonstrate this functionality in `./examples/promptui` project.
2023-09-25 17:20:03 +07:00
ian_Cin
08b6e5d3fb [AUR-390] Add prompt template and prompt component (#24)
* Export pipeline to config

* Export the input to config

* Preliminary creating UI dynamically

* Add test for config export

* Try out prompt UI

* Add example projects

* Fix test errors

* Standardize interface for retrieval

* Finalize the UI demo

* Update README.md

* Update README

* Refactor according to main

* Fix typing issue

* Add openai key to git-secret

* Add prompt template and prompt component

* Update test

* update tests

* revert docstring

---------

Co-authored-by: trducng <trungduc1992@gmail.com>
Co-authored-by: Nguyen Trung Duc (john) <john@cinnamon.is>
2023-09-25 14:38:22 +07:00
Nguyen Trung Duc (john)
c6dd01e820 [AUR-338, AUR-406, AUR-407] Export pipeline to config for PromptUI. Construct PromptUI dynamically based on config. (#16)
From pipeline > config > UI. Provide example project for promptui

- Pipeline to config: `kotaemon.contribs.promptui.config.export_pipeline_to_config`. The config follows schema specified in this document: https://cinnamon-ai.atlassian.net/wiki/spaces/ATM/pages/2748711193/Technical+Detail. Note: this implementation exclude the logs, which will be handled in AUR-408.
- Config to UI: `kotaemon.contribs.promptui.build_from_yaml`
- Example project is located at `examples/promptui/`
2023-09-21 14:27:23 +07:00
cin-jacky
c329c4c03f [AUR-362] Add In-memory vector store (#22)
* [AUR-362] Add In-memory vector store

* [AUR-362] fix delete fun input format

* [AUR-362] revise persist and from persist path to save and load

* [AUR-362] revise simple.py to in_memory.py
2023-09-20 17:51:50 +09:00
ian_Cin
b794051653 [AUR-421] base output post-processor that works using regex. (#20) 2023-09-19 19:54:44 +07:00
Nguyen Trung Duc (john)
2a3a23ecd7 [AUR-420] Provide document store base interface and an in-memory version (#21)
Document store handles storing and indexing Documents. It supports the following interfaces:

- add: add 1 or more documents into document store
- get: get a list of documents
- get_all: get all documents in a document store
- delete: delete 1 or more document
- save: persist a document store into disk
- load: load a document store from disk
2023-09-19 14:49:23 +07:00
Nguyen Trung Duc (john)
620b2b03ca [AUR-392, AUR-413, AUR-414] Define base vector store, and make use of ChromaVectorStore from llama_index. Indexing and retrieving vectors with vector store (#18)
Design the base interface of vector store, and apply it to the Chroma Vector Store (wrapped around llama_index's implementation). Provide the pipelines to populate and retrieve from vector store.
2023-09-14 14:18:20 +07:00
Nguyen Trung Duc (john)
c339912312 [AUR-389] Add base interface and embedding model (#17)
This change provides the base interface of an embedding, and wrap the Langchain's OpenAI embedding. Usage as follow:

```python
from kotaemon.embeddings import AzureOpenAIEmbeddings

model = AzureOpenAIEmbeddings(
    model="text-embedding-ada-002",
    deployment="embedding-deployment",
    openai_api_base="https://test.openai.azure.com/",
    openai_api_key="some-key",
)
output = model("Hello world")
```
2023-09-14 14:08:58 +07:00
ian_Cin
1061192731 [AUR-418] Add member public keys to git-secret: John, Ian, Tadashi, Jacky 2023-09-06 17:19:22 +07:00
trducng
f4596aa720 Fix import 2023-09-04 10:30:53 +07:00
Tuan Anh Nguyen Dang (Tadashi_Cin)
21350153d4 [AUR-391, AUR-393] Add Document and DocumentReader base (#6)
* Declare BaseComponent

* Brainstorming base class for LLM call

* Define base LLM

* Add tests

* Clean telemetry environment for accurate testing

* Fix README

* Fix typing

* add base document reader

* update test

* update requirements

* Cosmetic change

* update requirements

* reformat

---------

Co-authored-by: trducng <trungduc1992@gmail.com>
2023-08-31 11:24:12 +07:00
Nguyen Trung Duc (john)
4211315a54 [AUR-396] Scaffold prompt engineering code base section (#5) 2023-08-30 14:31:21 +07:00
ian_Cin
5241edbc46 [AUR-361] Setup pre-commit, pytest, GitHub actions, ssh-secret (#3)
Co-authored-by: trducng <trungduc1992@gmail.com>
2023-08-30 07:22:01 +07:00
Nguyen Trung Duc (john)
c3c25db48c [AUR-385, AUR-388] Declare BaseComponent and decide LLM call interface (#2)
- Use cases related to LLM call: https://cinnamon-ai.atlassian.net/browse/AUR-388?focusedCommentId=34873
- Sample usages: `test_llms_chat_models.py` and `test_llms_completion_models.py`:

```python
from kotaemon.llms.chats.openai import AzureChatOpenAI

model = AzureChatOpenAI(
    openai_api_base="https://test.openai.azure.com/",
    openai_api_key="some-key",
    openai_api_version="2023-03-15-preview",
    deployment_name="gpt35turbo",
    temperature=0,
    request_timeout=60,
)
output = model("hello world")
```

For the LLM-call component, I decide to wrap around Langchain's LLM models and Langchain's Chat models. And set the interface as follow:

- Completion LLM component:
```python
class CompletionLLM:

    def run_raw(self, text: str) -> LLMInterface:
        # Run text completion: str in -> LLMInterface out

    def run_batch_raw(self, text: list[str]) -> list[LLMInterface]:
        # Run text completion in batch: list[str] in -> list[LLMInterface] out

# run_document and run_batch_document just reuse run_raw and run_batch_raw, due to unclear use case
```

- Chat LLM component:
```python
class ChatLLM:
    def run_raw(self, text: str) -> LLMInterface:
        # Run chat completion (no chat history): str in -> LLMInterface out

    def run_batch_raw(self, text: list[str]) -> list[LLMInterface]:
        # Run chat completion in batch mode (no chat history): list[str] in -> list[LLMInterface] out

    def run_document(self, text: list[BaseMessage]) -> LLMInterface:
        # Run chat completion (with chat history): list[langchain's BaseMessage] in -> LLMInterface out

    def run_batch_document(self, text: list[list[BaseMessage]]) -> list[LLMInterface]:
        # Run chat completion in batch mode (with chat history): list[list[langchain's BaseMessage]] in -> list[LLMInterface] out
```

- The LLMInterface is as follow:

```python
@dataclass
class LLMInterface:
    text: list[str]
    completion_tokens: int = -1
    total_tokens: int = -1
    prompt_tokens: int = -1
    logits: list[list[float]] = field(default_factory=list)
```
2023-08-29 15:47:12 +07:00
Nguyen Trung Duc (john)
e9d1d5c118 [AUR-401] Disable Haystack telemetry with monkey patching (#1)
Sample Haystack log when running a pipeline. Note: the `pipeline.classname` can leak company information.

```json
{
  "hardware.cpus": 16,
  "hardware.gpus": 0,
  "libraries.colab": false,
  "libraries.cuda": false,
  "libraries.haystack": "1.20.0rc0",
  "libraries.ipython": false,
  "libraries.pytest": false,
  "libraries.ray": false,
  "libraries.torch": false,
  "libraries.transformers": "4.31.0",
  "os.containerized": false,
  "os.family": "Linux",
  "os.machine": "x86_64",
  "os.version": "6.2.0-26-generic",
  "pipeline.classname": "TempPipeline",
  "pipeline.config_hash": "07a8eddd5a6e512c0d898c6d9f445ed9",
  "pipeline.nodes.PromptNode": 1,
  "pipeline.nodes.Shaper": 1,
  "pipeline.nodes.WebRetriever": 1,
  "pipeline.run_parameters.debug": false,
  "pipeline.run_parameters.documents": [
    0
  ],
  "pipeline.run_parameters.file_paths": 0,
  "pipeline.run_parameters.labels": 0,
  "pipeline.run_parameters.meta": 1,
  "pipeline.run_parameters.params": false,
  "pipeline.run_parameters.queries": true,
  "pipeline.runs": 1,
  "pipeline.type": "Query",
  "python.version": "3.10.12"
}
```

Solution: Haystack telemetry uses the `telemetry` variable, `posthog` library and `HAYSTACK_TELEMETRY_ENABLED` envar. We set the envar to False and make sure the relevant objects are disabled.
2023-08-22 10:02:46 +07:00
trducng
043209fda7 Initiate repository 2023-08-16 14:56:48 +07:00