Skip to content

Commit c577cbc

Browse files
committed
Merge remote-tracking branch 'upstream/main' into lc_standard_tests
2 parents ab8a6f3 + 6a2315c commit c577cbc

File tree

31 files changed

+4242
-1777
lines changed

31 files changed

+4242
-1777
lines changed

.github/workflows/check_diffs.yml renamed to .github/workflows/CI.yml

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches: [main]
77
pull_request:
8+
workflow_dispatch: # Allows manual triggering from GitHub UI
89

910
# If another push to the same PR or branch happens while this workflow is still running,
1011
# cancel the earlier run in favor of the next run.
@@ -17,62 +18,36 @@ concurrency:
1718
cancel-in-progress: true
1819

1920
env:
20-
POETRY_VERSION: "1.7.1"
21+
POETRY_VERSION: "2.2.1"
2122

2223
jobs:
23-
build:
24-
runs-on: ubuntu-latest
25-
steps:
26-
- uses: actions/checkout@v4
27-
- uses: actions/setup-python@v5
28-
with:
29-
python-version: '3.10'
30-
- id: files
31-
uses: Ana06/get-changed-files@v2.2.0
32-
- id: set-matrix
33-
run: |
34-
python .github/scripts/check_diff.py ${{ steps.files.outputs.all }} >> $GITHUB_OUTPUT
35-
outputs:
36-
dirs-to-lint: ${{ steps.set-matrix.outputs.dirs-to-lint }}
37-
dirs-to-test: ${{ steps.set-matrix.outputs.dirs-to-test }}
3824
lint:
3925
name: cd ${{ matrix.working-directory }}
40-
needs: [ build ]
41-
if: ${{ needs.build.outputs.dirs-to-lint != '[]' }}
4226
strategy:
4327
matrix:
44-
working-directory: ${{ fromJson(needs.build.outputs.dirs-to-lint) }}
28+
working-directory:
29+
- "libs/oci"
30+
- "libs/oracledb"
4531
uses: ./.github/workflows/_lint.yml
4632
with:
4733
working-directory: ${{ matrix.working-directory }}
4834
secrets: inherit
4935

5036
test:
5137
name: cd ${{ matrix.working-directory }}
52-
needs: [ build ]
53-
if: ${{ needs.build.outputs.dirs-to-test != '[]' }}
5438
strategy:
5539
matrix:
56-
working-directory: ${{ fromJson(needs.build.outputs.dirs-to-test) }}
40+
working-directory:
41+
- "libs/oci"
42+
- "libs/oracledb"
5743
uses: ./.github/workflows/_test.yml
5844
with:
5945
working-directory: ${{ matrix.working-directory }}
6046
secrets: inherit
6147

62-
compile-integration-tests:
63-
name: cd ${{ matrix.working-directory }}
64-
needs: [ build ]
65-
if: ${{ needs.build.outputs.dirs-to-test != '[]' }}
66-
strategy:
67-
matrix:
68-
working-directory: ${{ fromJson(needs.build.outputs.dirs-to-test) }}
69-
uses: ./.github/workflows/_compile_integration_test.yml
70-
with:
71-
working-directory: ${{ matrix.working-directory }}
72-
secrets: inherit
7348
ci_success:
7449
name: "CI Success"
75-
needs: [build, lint, test, compile-integration-tests]
50+
needs: [lint, test]
7651
if: |
7752
always()
7853
runs-on: ubuntu-latest

.github/workflows/_compile_integration_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
description: "From which folder this pipeline executes"
1010

1111
env:
12-
POETRY_VERSION: "1.7.1"
12+
POETRY_VERSION: "2.2.1"
1313

1414
jobs:
1515
build:

.github/workflows/_lint.yml

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
description: "From which folder this pipeline executes"
1010

1111
env:
12-
POETRY_VERSION: "1.7.1"
12+
POETRY_VERSION: "2.2.1"
1313
WORKDIR: ${{ inputs.working-directory == '' && '.' || inputs.working-directory }}
1414

1515
# This env var allows us to get inline annotations when ruff has complaints.
@@ -42,17 +42,10 @@ jobs:
4242
working-directory: ${{ inputs.working-directory }}
4343
cache-key: lint-with-extras
4444

45-
- name: Check Poetry File
46-
shell: bash
45+
- name: Check Poetry configuration
4746
working-directory: ${{ inputs.working-directory }}
4847
run: |
49-
poetry check
50-
51-
- name: Check lock file
52-
shell: bash
53-
working-directory: ${{ inputs.working-directory }}
54-
run: |
55-
poetry lock --check
48+
poetry check --lock
5649
5750
- name: Install dependencies
5851
# Also installs dev/lint/test/typing dependencies, to ensure we have
@@ -65,38 +58,9 @@ jobs:
6558
# It doesn't matter how you change it, any change will cause a cache-bust.
6659
working-directory: ${{ inputs.working-directory }}
6760
run: |
68-
poetry install --with lint,typing
69-
70-
- name: Get .mypy_cache to speed up mypy
71-
uses: actions/cache@v4
72-
env:
73-
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "2"
74-
with:
75-
path: |
76-
${{ env.WORKDIR }}/.mypy_cache
77-
key: mypy-lint-${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python-version }}-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/poetry.lock', inputs.working-directory)) }}
78-
79-
80-
- name: Analysing the code with our lint
81-
working-directory: ${{ inputs.working-directory }}
82-
run: |
83-
make lint_package
84-
85-
- name: Install unit+integration test dependencies
86-
working-directory: ${{ inputs.working-directory }}
87-
run: |
88-
poetry install --with test,test_integration
89-
90-
- name: Get .mypy_cache_test to speed up mypy
91-
uses: actions/cache@v4
92-
env:
93-
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "2"
94-
with:
95-
path: |
96-
${{ env.WORKDIR }}/.mypy_cache_test
97-
key: mypy-test-${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python-version }}-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/poetry.lock', inputs.working-directory)) }}
61+
poetry install --with lint,typing,test,test_integration
9862
99-
- name: Analysing the code with our lint
63+
- name: Run linting
10064
working-directory: ${{ inputs.working-directory }}
10165
run: |
102-
make lint_tests
66+
make lint

.github/workflows/_release.yml

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,56 @@ on:
2121

2222
env:
2323
PYTHON_VERSION: "3.11"
24-
POETRY_VERSION: "1.7.1"
24+
POETRY_VERSION: "2.2.1"
2525

2626
jobs:
27+
test:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
33+
uses: "./.github/actions/poetry_setup"
34+
with:
35+
python-version: ${{ env.PYTHON_VERSION }}
36+
poetry-version: ${{ env.POETRY_VERSION }}
37+
working-directory: ${{ inputs.working-directory }}
38+
cache-key: release
39+
40+
- name: Import test dependencies
41+
run: |
42+
poetry lock
43+
poetry install --with test,test_integration
44+
working-directory: ${{ inputs.working-directory }}
45+
46+
- name: Run unit tests
47+
run: make tests
48+
working-directory: ${{ inputs.working-directory }}
49+
50+
# - name: Run integration tests
51+
# run: make integration_tests
52+
# working-directory: ${{ inputs.working-directory }}
53+
54+
- name: Get minimum versions
55+
working-directory: ${{ inputs.working-directory }}
56+
id: min-version
57+
run: |
58+
poetry run pip install packaging
59+
min_versions="$(poetry run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml)"
60+
echo "min-versions=$min_versions" >> "$GITHUB_OUTPUT"
61+
echo "min-versions=$min_versions"
62+
63+
- name: Run unit tests with minimum dependency versions
64+
if: ${{ steps.min-version.outputs.min-versions != '' }}
65+
env:
66+
MIN_VERSIONS: ${{ steps.min-version.outputs.min-versions }}
67+
run: |
68+
poetry run pip install $MIN_VERSIONS
69+
make tests
70+
working-directory: ${{ inputs.working-directory }}
71+
2772
build:
73+
needs: test
2874
if: github.ref == 'refs/heads/main'
2975
runs-on: ubuntu-latest
3076

@@ -134,10 +180,6 @@ jobs:
134180
135181
poetry run python -c "import $IMPORT_NAME; print(dir($IMPORT_NAME))"
136182
137-
- name: Import test dependencies
138-
run: poetry install --with test,test_integration
139-
working-directory: ${{ inputs.working-directory }}
140-
141183
# Overwrite the local version of the package with the test PyPI version.
142184
- name: Import published package (again)
143185
working-directory: ${{ inputs.working-directory }}
@@ -150,32 +192,6 @@ jobs:
150192
--extra-index-url https://test.pypi.org/simple/ \
151193
"$PKG_NAME==$VERSION"
152194
153-
- name: Run unit tests
154-
run: make tests
155-
working-directory: ${{ inputs.working-directory }}
156-
157-
- name: Run integration tests
158-
run: make integration_tests
159-
working-directory: ${{ inputs.working-directory }}
160-
161-
- name: Get minimum versions
162-
working-directory: ${{ inputs.working-directory }}
163-
id: min-version
164-
run: |
165-
poetry run pip install packaging
166-
min_versions="$(poetry run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml)"
167-
echo "min-versions=$min_versions" >> "$GITHUB_OUTPUT"
168-
echo "min-versions=$min_versions"
169-
170-
- name: Run unit tests with minimum dependency versions
171-
if: ${{ steps.min-version.outputs.min-versions != '' }}
172-
env:
173-
MIN_VERSIONS: ${{ steps.min-version.outputs.min-versions }}
174-
run: |
175-
poetry run pip install $MIN_VERSIONS
176-
make tests
177-
working-directory: ${{ inputs.working-directory }}
178-
179195
publish:
180196
needs:
181197
- build

.github/workflows/_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
description: "From which folder this pipeline executes"
1010

1111
env:
12-
POETRY_VERSION: "1.7.1"
12+
POETRY_VERSION: "2.2.1"
1313

1414
jobs:
1515
build:

libs/oci/Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ lint_tests: PYTHON_FILES=tests
2727
lint_tests: MYPY_CACHE=.mypy_cache_test
2828

2929
lint lint_diff lint_package lint_tests:
30-
poetry run ruff .
31-
poetry run ruff format $(PYTHON_FILES) --diff
32-
poetry run ruff --select I $(PYTHON_FILES)
33-
mkdir -p $(MYPY_CACHE); poetry run mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
30+
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff check $(PYTHON_FILES)
31+
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES) --diff
32+
[ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && poetry run mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
3433

3534
format format_diff:
3635
poetry run ruff format $(PYTHON_FILES)
37-
poetry run ruff --select I --fix $(PYTHON_FILES)
36+
poetry run ruff check --select I --fix $(PYTHON_FILES)
3837

3938
spell_check:
4039
poetry run codespell --toml pyproject.toml

libs/oci/README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ This repository includes two main integration categories:
3030
```python
3131
from langchain_oci import ChatOCIGenAI
3232

33-
llm = ChatOCIGenAI()
33+
llm = ChatOCIGenAI(
34+
model_id="MY_MODEL_ID",
35+
service_endpoint="MY_SERVICE_ENDPOINT",
36+
compartment_id="MY_COMPARTMENT_ID",
37+
model_kwargs={"max_tokens": 1024}, # Use max_completion_tokens instead of max_tokens for OpenAI models
38+
auth_profile="MY_AUTH_PROFILE",
39+
is_stream=True,
40+
auth_type="SECURITY_TOKEN"
3441
llm.invoke("Sing a ballad of LangChain.")
3542
```
3643

@@ -54,6 +61,24 @@ embeddings = OCIGenAIEmbeddings()
5461
embeddings.embed_query("What is the meaning of life?")
5562
```
5663

64+
### 4. Use Structured Output
65+
`ChatOCIGenAI` supports structured output.
66+
67+
<sub>**Note:** The default method is `function_calling`. If default method returns `None` (e.g. for Gemini models), try `json_schema` or `json_mode`.</sub>
68+
69+
```python
70+
from langchain_oci import ChatOCIGenAI
71+
from pydantic import BaseModel
72+
73+
class Joke(BaseModel):
74+
setup: str
75+
punchline: str
76+
77+
llm = ChatOCIGenAI()
78+
structured_llm = llm.with_structured_output(Joke)
79+
structured_llm.invoke("Tell me a joke about programming")
80+
```
81+
5782

5883
## OCI Data Science Model Deployment Examples
5984

0 commit comments

Comments
 (0)