From c572e2714580ecfb046313c68d5c539a48b39e4c Mon Sep 17 00:00:00 2001 From: vasilije Date: Wed, 19 Feb 2025 15:15:59 -0800 Subject: [PATCH 01/25] Draft ollama test --- .github/workflows/test_ollama.yml | 59 +++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/test_ollama.yml diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml new file mode 100644 index 00000000..8af4bbb9 --- /dev/null +++ b/.github/workflows/test_ollama.yml @@ -0,0 +1,59 @@ +name: test | ollama + +on: + schedule: + - cron: "0 0 * * *" # daily schedule + workflow_dispatch: + +jobs: + update-insights: + runs-on: ubuntu-latest + services: + ollama: + image: ollama/ollama + ports: + - 11434:11434 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GH_PAT }} # Use PAT instead of default token + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Cache pip packages + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Wait for Ollama to be ready + run: | + for i in {1..30}; do + curl -s http://localhost:11434/api/tags && break + sleep 2 + done + + - name: Pull Model + run: | + curl -X POST http://localhost:11434/api/pull -d '{"name": "mistral"}' + + + run_simple_example_test: + uses: ./.github/workflows/reusable_python_example.yml + with: + example-location: ./examples/python/simple_example.py + secrets: + LLM_API_KEY: ${{ secrets.OPENAI_API_KEY }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + GRAPHISTRY_USERNAME: ${{ secrets.GRAPHISTRY_USERNAME }} + GRAPHISTRY_PASSWORD: ${{ secrets.GRAPHISTRY_PASSWORD }} \ No newline at end of file From 2de364b93731f9074af118c6afa114270f678c46 Mon Sep 17 00:00:00 2001 From: vasilije Date: Wed, 19 Feb 2025 18:02:33 -0800 Subject: [PATCH 02/25] Ollama test end to end --- .github/workflows/test_ollama.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 8af4bbb9..2473de3c 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -1,9 +1,9 @@ name: test | ollama on: - schedule: - - cron: "0 0 * * *" # daily schedule workflow_dispatch: + pull_request: + types: [ labeled, synchronize ] jobs: update-insights: @@ -45,7 +45,10 @@ jobs: - name: Pull Model run: | - curl -X POST http://localhost:11434/api/pull -d '{"name": "mistral"}' + curl -X POST http://localhost:11434/api/pull -d '{"name": "ollama/llama3.2"}' + - name: Pull Embedding Model + run: | + curl -X POST http://localhost:11434/api/pull -d '{"name": "avr/sfr-embedding-mistral:latest"}' run_simple_example_test: @@ -53,7 +56,15 @@ jobs: with: example-location: ./examples/python/simple_example.py secrets: - LLM_API_KEY: ${{ secrets.OPENAI_API_KEY }} + LLM_API_KEY: "ollama" OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} GRAPHISTRY_USERNAME: ${{ secrets.GRAPHISTRY_USERNAME }} - GRAPHISTRY_PASSWORD: ${{ secrets.GRAPHISTRY_PASSWORD }} \ No newline at end of file + GRAPHISTRY_PASSWORD: ${{ secrets.GRAPHISTRY_PASSWORD }} + LLM_PROVIDER: "ollama" + LLM_ENDPOINT: "http://localhost:11434" + LLM_MODEL: "ollama/llama3.2" + EMBEDDING_PROVIDER: "ollama" + EMBEDDING_MODEL: "avr/sfr-embedding-mistral:latest" + EMBEDDING_ENDPOINT: "http://localhost:11434/api/embeddings" + EMBEDDING_DIMENSIONS: 4096 + HUGGINGFACE_TOKENIZER: "Salesforce/SFR-Embedding-Mistral" \ No newline at end of file From 8ebd9a7d8a0db78b3058c5a24c76c67cffcfa7fb Mon Sep 17 00:00:00 2001 From: vasilije Date: Wed, 19 Feb 2025 18:10:49 -0800 Subject: [PATCH 03/25] Ollama test end to end --- .github/workflows/test_ollama.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 2473de3c..0ff0517b 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -56,10 +56,10 @@ jobs: with: example-location: ./examples/python/simple_example.py secrets: - LLM_API_KEY: "ollama" OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} GRAPHISTRY_USERNAME: ${{ secrets.GRAPHISTRY_USERNAME }} GRAPHISTRY_PASSWORD: ${{ secrets.GRAPHISTRY_PASSWORD }} + LLM_API_KEY: "ollama" LLM_PROVIDER: "ollama" LLM_ENDPOINT: "http://localhost:11434" LLM_MODEL: "ollama/llama3.2" From 9d0d96eb1cd5a9262c9605b35491b32d00acc358 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 13:43:04 -0800 Subject: [PATCH 04/25] Fix ollama --- .github/workflows/test_ollama.yml | 83 ++++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 0ff0517b..d85de95e 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -6,7 +6,7 @@ on: types: [ labeled, synchronize ] jobs: - update-insights: + setup-ollama: runs-on: ubuntu-latest services: ollama: @@ -17,8 +17,6 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - with: - token: ${{ secrets.GH_PAT }} # Use PAT instead of default token - name: Set up Python uses: actions/setup-python@v4 @@ -39,32 +37,69 @@ jobs: - name: Wait for Ollama to be ready run: | for i in {1..30}; do - curl -s http://localhost:11434/api/tags && break + if curl -s http://localhost:11434/api/tags > /dev/null; then + echo "Ollama is ready" + exit 0 + fi + echo "Waiting for Ollama... attempt $i" sleep 2 done + echo "Ollama failed to start" + exit 1 - - name: Pull Model + - name: Pull Models run: | curl -X POST http://localhost:11434/api/pull -d '{"name": "ollama/llama3.2"}' - - name: Pull Embedding Model - run: | curl -X POST http://localhost:11434/api/pull -d '{"name": "avr/sfr-embedding-mistral:latest"}' - run_simple_example_test: - uses: ./.github/workflows/reusable_python_example.yml - with: - example-location: ./examples/python/simple_example.py - secrets: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - GRAPHISTRY_USERNAME: ${{ secrets.GRAPHISTRY_USERNAME }} - GRAPHISTRY_PASSWORD: ${{ secrets.GRAPHISTRY_PASSWORD }} - LLM_API_KEY: "ollama" - LLM_PROVIDER: "ollama" - LLM_ENDPOINT: "http://localhost:11434" - LLM_MODEL: "ollama/llama3.2" - EMBEDDING_PROVIDER: "ollama" - EMBEDDING_MODEL: "avr/sfr-embedding-mistral:latest" - EMBEDDING_ENDPOINT: "http://localhost:11434/api/embeddings" - EMBEDDING_DIMENSIONS: 4096 - HUGGINGFACE_TOKENIZER: "Salesforce/SFR-Embedding-Mistral" \ No newline at end of file + needs: setup-ollama + runs-on: ubuntu-latest + services: + ollama: + image: ollama/ollama + ports: + - 11434:11434 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Wait for Ollama to be ready + run: | + for i in {1..30}; do + if curl -s http://localhost:11434/api/tags > /dev/null; then + echo "Ollama is ready" + exit 0 + fi + echo "Waiting for Ollama... attempt $i" + sleep 2 + done + echo "Ollama failed to start" + exit 1 + + - name: Run example test + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + GRAPHISTRY_USERNAME: ${{ secrets.GRAPHISTRY_USERNAME }} + GRAPHISTRY_PASSWORD: ${{ secrets.GRAPHISTRY_PASSWORD }} + LLM_API_KEY: "ollama" + LLM_PROVIDER: "ollama" + LLM_ENDPOINT: "http://localhost:11434" + LLM_MODEL: "ollama/llama3.2" + EMBEDDING_PROVIDER: "ollama" + EMBEDDING_MODEL: "avr/sfr-embedding-mistral:latest" + EMBEDDING_ENDPOINT: "http://localhost:11434/api/embeddings" + EMBEDDING_DIMENSIONS: "4096" + HUGGINGFACE_TOKENIZER: "Salesforce/SFR-Embedding-Mistral" + run: python ./examples/python/simple_example.py \ No newline at end of file From b4088bec29d8a1881f84f73ffcabac0c88cec056 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 13:51:30 -0800 Subject: [PATCH 05/25] Fix ollama --- .github/workflows/upgrade_deps.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upgrade_deps.yml b/.github/workflows/upgrade_deps.yml index 934a3ed6..327ee08c 100644 --- a/.github/workflows/upgrade_deps.yml +++ b/.github/workflows/upgrade_deps.yml @@ -2,8 +2,29 @@ name: Update Poetry Dependencies on: schedule: - - cron: '0 3 * * 0' + - cron: '0 3 * * 0' # Runs at 3 AM every Sunday + push: + paths: + - 'poetry.lock' + - 'pyproject.toml' + branches: + - main + - dev + pull_request: + paths: + - 'poetry.lock' + - 'pyproject.toml' + types: [opened, synchronize, reopened] + branches: + - main + - dev workflow_dispatch: + inputs: + debug_enabled: + type: boolean + description: 'Run the update with debug logging' + required: false + default: false jobs: update-dependencies: From b670697b8bbbef2bbebe1acbdea4dd0239c6f90a Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 13:55:06 -0800 Subject: [PATCH 06/25] Fix ollama --- .github/workflows/test_ollama.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index d85de95e..d6e9d417 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -74,6 +74,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt + pip install ollama-python requests - name: Wait for Ollama to be ready run: | From bfe039d2aaa103645cfd81e86ff9b63c4b36221a Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 13:59:56 -0800 Subject: [PATCH 07/25] Fix ollama --- .github/workflows/test_ollama.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index d6e9d417..1ac8377e 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -73,7 +73,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt pip install ollama-python requests - name: Wait for Ollama to be ready From 6bc4f6ae24a6fb65dfe44ccdd0c1735df7510d9a Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 14:05:27 -0800 Subject: [PATCH 08/25] Fix ollama --- .github/workflows/test_ollama.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 1ac8377e..939d10ce 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -32,7 +32,9 @@ jobs: ${{ runner.os }}-pip- - name: Install dependencies - run: pip install -r requirements.txt + run: | + python -m pip install --upgrade pip + pip install ollama-python requests - name: Wait for Ollama to be ready run: | From 96adcfbe4e74e2c38108c9406a08e7e784bef53c Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 14:16:10 -0800 Subject: [PATCH 09/25] Fix ollama --- .github/workflows/test_ollama.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 939d10ce..5e60a7b8 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -67,10 +67,21 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 + - name: Setup Python + uses: actions/setup-python@v5 with: - python-version: "3.x" + python-version: '3.12.x' + + - name: Install Poetry + uses: snok/install-poetry@v1.4.1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + + - name: Install dependencies + run: | + poetry install --no-interaction --all-extras - name: Install dependencies run: | From c06c28d7a63ce8c8fbe50eb7a92bad7e000fd901 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 14:27:35 -0800 Subject: [PATCH 10/25] Fix ollama --- .github/workflows/test_ollama.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 5e60a7b8..71cedf94 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -115,4 +115,4 @@ jobs: EMBEDDING_ENDPOINT: "http://localhost:11434/api/embeddings" EMBEDDING_DIMENSIONS: "4096" HUGGINGFACE_TOKENIZER: "Salesforce/SFR-Embedding-Mistral" - run: python ./examples/python/simple_example.py \ No newline at end of file + run: poetry run python ./examples/python/simple_example.py \ No newline at end of file From edd681f7de2beee66ac64df6e5417eef0b18121b Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 14:46:58 -0800 Subject: [PATCH 11/25] Fix ollama --- .github/workflows/test_ollama.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 71cedf94..908a9eb8 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -101,6 +101,12 @@ jobs: echo "Ollama failed to start" exit 1 + - name: Dump Docker logs + run: | + docker ps + docker logs $(docker ps --filter "ancestor=ollama/ollama" --format "{{.ID}}") + + - name: Run example test env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} From 02b0109d0ed9e3832cf132546e89185d485c7ae1 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 15:36:04 -0800 Subject: [PATCH 12/25] Fix ollama --- .github/workflows/test_ollama.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 908a9eb8..5fabbb59 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -86,7 +86,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install ollama-python requests + poetry install ollama-python requests + poetry install transformers - name: Wait for Ollama to be ready run: | From a91e83eafaac717509402cd62515080718138b77 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 15:48:38 -0800 Subject: [PATCH 13/25] Fix ollama --- .github/workflows/test_ollama.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 5fabbb59..6456f711 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -85,7 +85,6 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip poetry install ollama-python requests poetry install transformers @@ -113,6 +112,7 @@ jobs: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} GRAPHISTRY_USERNAME: ${{ secrets.GRAPHISTRY_USERNAME }} GRAPHISTRY_PASSWORD: ${{ secrets.GRAPHISTRY_PASSWORD }} + PYTHONFAULTHANDLER: 1 LLM_API_KEY: "ollama" LLM_PROVIDER: "ollama" LLM_ENDPOINT: "http://localhost:11434" From 326c41843f281d68f68f6b4277c32fb6c09b3517 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 15:56:30 -0800 Subject: [PATCH 14/25] Fix ollama --- .github/workflows/test_ollama.yml | 12 +--- cognee/infrastructure/llm/ollama/adapter.py | 65 ++++++++++++++++++++- 2 files changed, 64 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 6456f711..b66de438 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -21,20 +21,12 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.x" - - - name: Cache pip packages - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- + python-version: "3.12.x" - name: Install dependencies run: | python -m pip install --upgrade pip - pip install ollama-python requests + pip install requests - name: Wait for Ollama to be ready run: | diff --git a/cognee/infrastructure/llm/ollama/adapter.py b/cognee/infrastructure/llm/ollama/adapter.py index 4eb39273..ed0ef31b 100644 --- a/cognee/infrastructure/llm/ollama/adapter.py +++ b/cognee/infrastructure/llm/ollama/adapter.py @@ -1,20 +1,28 @@ +from sys import api_version from typing import Type from pydantic import BaseModel import instructor from cognee.infrastructure.llm.llm_interface import LLMInterface from cognee.infrastructure.llm.config import get_llm_config from openai import OpenAI - +import base64 +from pathlib import Path +import os class OllamaAPIAdapter(LLMInterface): - """Adapter for a Generic API LLM provider using instructor with an OpenAI backend.""" + """Adapter for a Ollama API LLM provider using instructor with an OpenAI backend.""" + + api_version: str + + MAX_RETRIES = 5 - def __init__(self, endpoint: str, api_key: str, model: str, name: str, max_tokens: int): + def __init__(self, endpoint: str, api_key: str, model: str, name: str, max_tokens: int, api_version: str = None) -> None: self.name = name self.model = model self.api_key = api_key self.endpoint = endpoint self.max_tokens = max_tokens + self.api_version= api_version self.aclient = instructor.from_openai( OpenAI(base_url=self.endpoint, api_key=self.api_key), mode=instructor.Mode.JSON @@ -42,3 +50,54 @@ async def acreate_structured_output( ) return response + + + def create_transcript(self, input): + """Generate a audio transcript from a user query.""" + + if not os.path.isfile(input): + raise FileNotFoundError(f"The file {input} does not exist.") + + # with open(input, 'rb') as audio_file: + # audio_data = audio_file.read() + + transcription = self.aclient.transcription( + model=self.transcription_model, + file=Path(input), + api_key=self.api_key, + api_base=self.endpoint, + api_version=self.api_version, + max_retries=self.MAX_RETRIES, + ) + + return transcription + + def transcribe_image(self, input) -> BaseModel: + with open(input, "rb") as image_file: + encoded_image = base64.b64encode(image_file.read()).decode("utf-8") + + return self.aclient.completion( + model=self.model, + messages=[ + { + "role": "user", + "content": [ + { + "type": "text", + "text": "What’s in this image?", + }, + { + "type": "image_url", + "image_url": { + "url": f"data:image/jpeg;base64,{encoded_image}", + }, + }, + ], + } + ], + api_key=self.api_key, + api_base=self.endpoint, + api_version=self.api_version, + max_tokens=300, + max_retries=self.MAX_RETRIES, + ) \ No newline at end of file From 92602aa34f8fa53bb5d089eaab4d82ede46bdff1 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 16:02:08 -0800 Subject: [PATCH 15/25] Fix ollama --- .github/workflows/test_ollama.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index b66de438..bd7da456 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -77,7 +77,7 @@ jobs: - name: Install dependencies run: | - poetry install ollama-python requests + poetry install requests poetry install transformers - name: Wait for Ollama to be ready From f2d09090e1d96c71bb266fabca00da91949d3545 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 16:06:05 -0800 Subject: [PATCH 16/25] Fix ollama --- .github/workflows/test_ollama.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index bd7da456..222f8cb7 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -75,11 +75,6 @@ jobs: run: | poetry install --no-interaction --all-extras - - name: Install dependencies - run: | - poetry install requests - poetry install transformers - - name: Wait for Ollama to be ready run: | for i in {1..30}; do @@ -107,7 +102,7 @@ jobs: PYTHONFAULTHANDLER: 1 LLM_API_KEY: "ollama" LLM_PROVIDER: "ollama" - LLM_ENDPOINT: "http://localhost:11434" + LLM_ENDPOINT: "http://localhost:11434/api/generate" LLM_MODEL: "ollama/llama3.2" EMBEDDING_PROVIDER: "ollama" EMBEDDING_MODEL: "avr/sfr-embedding-mistral:latest" From 97465f168aec3189022c57419ccf83653d2ac7a7 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 16:06:56 -0800 Subject: [PATCH 17/25] Fix ollama --- .github/workflows/test_ollama.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 222f8cb7..e18b4dee 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -19,14 +19,20 @@ jobs: uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.12.x" + - name: Install Poetry + uses: snok/install-poetry@v1.4.1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install requests + poetry install --no-interaction --all-extras - name: Wait for Ollama to be ready run: | From 73662b8b01d64f5d54b2f1545e51eb0ee59925da Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 16:12:20 -0800 Subject: [PATCH 18/25] Fix ollama --- .github/workflows/test_ollama.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index e18b4dee..bddf708d 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -108,7 +108,7 @@ jobs: PYTHONFAULTHANDLER: 1 LLM_API_KEY: "ollama" LLM_PROVIDER: "ollama" - LLM_ENDPOINT: "http://localhost:11434/api/generate" + LLM_ENDPOINT: "http://127.0.0.1:11434" LLM_MODEL: "ollama/llama3.2" EMBEDDING_PROVIDER: "ollama" EMBEDDING_MODEL: "avr/sfr-embedding-mistral:latest" From 90d96aa6ad8129cf415d27bec87d7e4bd4b94303 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 16:17:50 -0800 Subject: [PATCH 19/25] Fix ollama --- .github/workflows/test_ollama.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index bddf708d..edfd2891 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -49,7 +49,7 @@ jobs: - name: Pull Models run: | - curl -X POST http://localhost:11434/api/pull -d '{"name": "ollama/llama3.2"}' + curl -X POST http://localhost:11434/api/pull -d '{"name": "llama3.2"}' curl -X POST http://localhost:11434/api/pull -d '{"name": "avr/sfr-embedding-mistral:latest"}' run_simple_example_test: From 3a88b94d0185424c007fad794475c92d65e7e640 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 16:25:08 -0800 Subject: [PATCH 20/25] Fix ollama --- .github/workflows/test_ollama.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index edfd2891..35e06311 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -112,7 +112,7 @@ jobs: LLM_MODEL: "ollama/llama3.2" EMBEDDING_PROVIDER: "ollama" EMBEDDING_MODEL: "avr/sfr-embedding-mistral:latest" - EMBEDDING_ENDPOINT: "http://localhost:11434/api/embeddings" + EMBEDDING_ENDPOINT: "http://127.0.0.1:11434/api/embeddings" EMBEDDING_DIMENSIONS: "4096" HUGGINGFACE_TOKENIZER: "Salesforce/SFR-Embedding-Mistral" run: poetry run python ./examples/python/simple_example.py \ No newline at end of file From 11442df1aaed717e74da5bccbe3908a78501b1e8 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 16:41:42 -0800 Subject: [PATCH 21/25] Fix ollama --- .github/workflows/test_ollama.yml | 50 ++++++++----------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 35e06311..5a1af170 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -8,44 +8,7 @@ on: jobs: setup-ollama: runs-on: ubuntu-latest - services: - ollama: - image: ollama/ollama - ports: - - 11434:11434 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.12.x" - - - name: Install Poetry - uses: snok/install-poetry@v1.4.1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - installer-parallel: true - - name: Install dependencies - run: | - poetry install --no-interaction --all-extras - - - name: Wait for Ollama to be ready - run: | - for i in {1..30}; do - if curl -s http://localhost:11434/api/tags > /dev/null; then - echo "Ollama is ready" - exit 0 - fi - echo "Waiting for Ollama... attempt $i" - sleep 2 - done - echo "Ollama failed to start" - exit 1 - name: Pull Models run: | @@ -53,7 +16,7 @@ jobs: curl -X POST http://localhost:11434/api/pull -d '{"name": "avr/sfr-embedding-mistral:latest"}' run_simple_example_test: - needs: setup-ollama + runs-on: ubuntu-latest services: ollama: @@ -80,6 +43,17 @@ jobs: - name: Install dependencies run: | poetry install --no-interaction --all-extras + steps: + - name: Install ollama + run: curl -fsSL https://ollama.com/install.sh | sh + - name: Run ollama + run: | + ollama serve & + ollama pull llama3.2 & + ollama pull avr/sfr-embedding-mistral:latest + - name: Call ollama API + run: | + curl -d '{"model": "llama3.2", "stream": false, "prompt":"Whatever I say, asnwer with Yes"}' http://localhost:11434/api/generate - name: Wait for Ollama to be ready run: | From 1dfb0dd58b7dd5e8ec6a8dbd268e006a342b0b80 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 16:42:09 -0800 Subject: [PATCH 22/25] Fix ollama --- .github/workflows/test_ollama.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 5a1af170..15e1b3bd 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -6,14 +6,6 @@ on: types: [ labeled, synchronize ] jobs: - setup-ollama: - runs-on: ubuntu-latest - - - - name: Pull Models - run: | - curl -X POST http://localhost:11434/api/pull -d '{"name": "llama3.2"}' - curl -X POST http://localhost:11434/api/pull -d '{"name": "avr/sfr-embedding-mistral:latest"}' run_simple_example_test: @@ -43,7 +35,7 @@ jobs: - name: Install dependencies run: | poetry install --no-interaction --all-extras - steps: + - name: Install ollama run: curl -fsSL https://ollama.com/install.sh | sh - name: Run ollama From 4c4723b7e0e3d4a00c4ba8c2f3ca547106e4e2a9 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 16:55:41 -0800 Subject: [PATCH 23/25] Fix ollama --- .github/workflows/test_ollama.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 15e1b3bd..976220d7 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -74,7 +74,7 @@ jobs: PYTHONFAULTHANDLER: 1 LLM_API_KEY: "ollama" LLM_PROVIDER: "ollama" - LLM_ENDPOINT: "http://127.0.0.1:11434" + LLM_ENDPOINT: "http://127.0.0.1:11434/v1/chat/completions" LLM_MODEL: "ollama/llama3.2" EMBEDDING_PROVIDER: "ollama" EMBEDDING_MODEL: "avr/sfr-embedding-mistral:latest" From 846c45e54dac5bb3daa23df083f265454d967356 Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 17:18:05 -0800 Subject: [PATCH 24/25] Fix ollama --- .github/workflows/test_ollama.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_ollama.yml b/.github/workflows/test_ollama.yml index 976220d7..f0312a81 100644 --- a/.github/workflows/test_ollama.yml +++ b/.github/workflows/test_ollama.yml @@ -74,7 +74,7 @@ jobs: PYTHONFAULTHANDLER: 1 LLM_API_KEY: "ollama" LLM_PROVIDER: "ollama" - LLM_ENDPOINT: "http://127.0.0.1:11434/v1/chat/completions" + LLM_ENDPOINT: "http://127.0.0.1:11434/api/generate" LLM_MODEL: "ollama/llama3.2" EMBEDDING_PROVIDER: "ollama" EMBEDDING_MODEL: "avr/sfr-embedding-mistral:latest" From 2c0bfc87a6d15d324527a9a3285d2254907ad0ba Mon Sep 17 00:00:00 2001 From: vasilije Date: Fri, 21 Feb 2025 17:45:29 -0800 Subject: [PATCH 25/25] Fix ollama --- .github/workflows/test_gemini.yml | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/test_gemini.yml diff --git a/.github/workflows/test_gemini.yml b/.github/workflows/test_gemini.yml new file mode 100644 index 00000000..e5bf0520 --- /dev/null +++ b/.github/workflows/test_gemini.yml @@ -0,0 +1,33 @@ +name: test | gemini + +on: + workflow_dispatch: + pull_request: + types: [labeled, synchronize] + + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + run_simple_example_test: + uses: ./.github/workflows/reusable_python_example.yml + with: + example-location: ./examples/python/simple_example.py + secrets: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + GRAPHISTRY_USERNAME: ${{ secrets.GRAPHISTRY_USERNAME }} + GRAPHISTRY_PASSWORD: ${{ secrets.GRAPHISTRY_PASSWORD }} + EMBEDDING_PROVIDER: "gemini" + EMBEDDING_API_KEY: ${{ secrets.GEMINI_API_KEY }} + EMBEDDING_MODEL: "gemini/text-embedding-004" + EMBEDDING_ENDPOINT: "https://generativelanguage.googleapis.com/v1beta/models/text-embedding-004" + EMBEDDING_API_VERSION: "v1beta" + EMBEDDING_DIMENSIONS: 768 + EMBEDDING_MAX_TOKENS: 8076 + LLM_PROVIDER: "gemini" + LLM_API_KEY: ${{ secrets.GEMINI_API_KEY }} + LLM_MODEL: "gemini/gemini-1.5-flash" + LLM_ENDPOINT: "https://generativelanguage.googleapis.com/" + LLM_API_VERSION: "v1beta"