Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CHAT_COMPLETION_MODEL_ID=TpHmCB8s

TASKINGAI_HOST=https://api.test199.com

TEXT_EMBEDDING_MODEL_ID=TpEZlEOK

TASKINGAI_API_KEY=taxy8i3OCfeJfh0eXW0h00cF2QT7nWyy
78 changes: 78 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Publish Package

on:
push:
tags: ["v*.*.*"]
paths-ignore:
- '**.md'
- '**.svg'
- '**.jpg'
- '**.png'

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
environment: test
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set short SHA
run: echo "IMAGE_TAG=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV

- name: Check for git tag version
id: get_tag
run: |
TAG=$(git describe --tags --exact-match 2> /dev/null || echo "")
if [[ -n "$TAG" ]]; then
echo "IMAGE_TAG=${TAG}" >> $GITHUB_ENV
fi

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install Dependencies
run: pip install -r requirements.txt

- name: Run Version Verification
run: |
python -c "from config import CONFIG; import os; current_tag = os.getenv('IMAGE_TAG'); assert CONFIG.VERSION == current_tag, 'Version mismatch: Expected {} but got {}'.format(CONFIG.VERSION, current_tag); print('Version matched!')"


- name: Install Twine
run: |
python -m pip install --upgrade pip
pip install twine

- name: Run Tests
env:
CLIENT_TEST_ENV: ${{ secrets.CLIENT_TEST_ENV }}
run: |
echo "$CLIENT_TEST_ENV" > .env
bash ./test/run_test.sh

- name: Build Package
run: python setup.py sdist bdist_wheel

- name: Publish Package
run: twine upload dist/*
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.IMAGE_TAG }}
release_name: Release ${{ env.IMAGE_TAG }}
body: |
This is the release for version ${{ env.IMAGE_TAG }}.
draft: false
prerelease: false
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Run test

on:
pull_request:
branches: [ "master" ]
paths-ignore:
- '**.md'
- '**.svg'
- '**.jpg'
- '**.png'

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
environment: test
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set short SHA
run: echo "IMAGE_TAG=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV

- name: Check for git tag version
id: get_tag
run: |
TAG=$(git describe --tags --exact-match 2> /dev/null || echo "")
if [[ -n "$TAG" ]]; then
echo "IMAGE_TAG=${TAG}" >> $GITHUB_ENV
fi

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install Dependencies
run: |
pip install -r requirements.txt
pip install -r test_requirements.txt

- name: Run Tests
env:
CLIENT_TEST_ENV: ${{ secrets.CLIENT_TEST_ENV }}
run: |
echo "$CLIENT_TEST_ENV" > .env
bash ./test/run_test.sh
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ setuptools>=21.0.0
httpx>=0.23.0
pydantic>=2.5.0


2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
url="https://www.tasking.ai",
keywords=["TaskingAI", "LLM", "AI"],
install_requires=REQUIRES,
packages=find_packages(exclude=["test", "test.*"]),
packages=find_packages(exclude=["test", "test.*", "examples", "examples.*"]),
include_package_data=True,
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion taskingai/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__title__ = "taskingai"
__version__ = "0.1.3"
__version__ = "0.2.0"
14 changes: 13 additions & 1 deletion test/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import os
from dotenv import load_dotenv
import taskingai

load_dotenv()


class Config:
Expand All @@ -11,6 +15,14 @@ class Config:
if not chat_completion_model_id:
raise ValueError("chat_completion_model_id is not defined")

sleep_time = 1
taskingai_host = os.environ.get("TASKINGAI_HOST")
if not taskingai_host:
raise ValueError("taskingai_host is not defined")

taskingai_apikey = os.environ.get("TASKINGAI_API_KEY")
if not taskingai_apikey:
raise ValueError("taskingai_apikey is not defined")

taskingai.init(api_key=taskingai_apikey, host=taskingai_host)

sleep_time = 1
4 changes: 3 additions & 1 deletion test/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export PYTHONPATH="${PYTHONPATH}:${parent_dir}"

echo "Starting tests..."

pytest -q --tb=no
pytest ./test/testcase/test_sync
sleep 5
pytest ./test/testcase/test_async

echo "Tests completed."

22 changes: 9 additions & 13 deletions test/testcase/test_async/test_async_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,18 @@ async def test_a_delete_assistant(self):

assistants = await a_list_assistants(limit=100)
old_nums = len(assistants)
for i, v in enumerate(assistants):
for index, v in enumerate(assistants):
assistant_id = v.assistant_id

# Delete an assistant.

await a_delete_assistant(assistant_id=str(assistant_id))

# List assistants.

new_assistants = await a_list_assistants()
assistant_ids = [j.assistant_id for j in new_assistants]
pytest.assume(assistant_id not in assistant_ids)
new_nums = len(new_assistants)
pytest.assume(new_nums == old_nums - 1 - i)
if index == old_nums - 1:
new_assistants = await a_list_assistants()
new_nums = len(new_assistants)
pytest.assume(new_nums == 0)


@pytest.mark.test_async
Expand Down Expand Up @@ -210,12 +208,10 @@ async def test_a_delete_chat(self):
await a_delete_chat(assistant_id=self.assistant_id, chat_id=str(chat_id))

# List chats.

new_chats = await a_list_chats(assistant_id=self.assistant_id)
chat_ids = [i.chat_id for i in new_chats]
pytest.assume(chat_id not in chat_ids)
new_nums = len(new_chats)
pytest.assume(new_nums == old_nums - 1 - index)
if index == old_nums - 1:
new_chats = await a_list_chats(assistant_id=self.assistant_id)
new_nums = len(new_chats)
pytest.assume(new_nums == 0)


@pytest.mark.test_async
Expand Down
36 changes: 17 additions & 19 deletions test/testcase/test_async/test_async_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ async def test_a_update_collection(self):
async def test_a_delete_collection(self):
# List collections.
old_res = await a_list_collections(order="desc", limit=100, after=None, before=None)

old_nums = len(old_res)
for index, collection in enumerate(old_res):
collection_id = collection.collection_id
# Delete a collection.
await a_delete_collection(collection_id=collection_id)

new_collections = await a_list_collections(order="desc", limit=100, after=None, before=None)
# List collections.
collection_ids = [c.collection_id for c in new_collections]
pytest.assume(collection_id not in collection_ids)
if index == old_nums - 1:
new_collections = await a_list_collections(order="desc", limit=100, after=None, before=None)
# List collections.
new_nums = len(new_collections)
pytest.assume(new_nums == 0)


@pytest.mark.test_async
Expand Down Expand Up @@ -234,13 +234,13 @@ async def test_a_delete_record(self):
await a_delete_record(collection_id=self.collection_id, record_id=record_id)

# List records.

new_records = await a_list_records(collection_id=self.collection_id, order="desc", limit=20, after=None,
before=None)
record_ids = [record.record_id for record in new_records]
pytest.assume(record_id not in record_ids)
new_nums = len(new_records)
pytest.assume(new_nums == old_nums - 1 - index)
if index == old_nums - 1:
new_records = await a_list_records(collection_id=self.collection_id, order="desc", limit=20, after=None,
before=None)
record_ids = [record.record_id for record in new_records]
pytest.assume(record_id not in record_ids)
new_nums = len(new_records)
pytest.assume(new_nums == 0)


@pytest.mark.test_async
Expand Down Expand Up @@ -352,9 +352,7 @@ async def test_delete_chunk(self):
delete_chunk(collection_id=self.collection_id, chunk_id=chunk_id)

# List chunks.

new_chunks = list_chunks(collection_id=self.collection_id)
chunk_ids = [chunk.chunk_id for chunk in new_chunks]
pytest.assume(chunk_id not in chunk_ids)
new_nums = len(new_chunks)
pytest.assume(new_nums == old_nums - 1 - index)
if index == old_nums-1:
new_chunks = list_chunks(collection_id=self.collection_id)
new_nums = len(new_chunks)
pytest.assume(new_nums == 0)
14 changes: 4 additions & 10 deletions test/testcase/test_async/test_async_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,7 @@ async def test_a_delete_action(self):
# Delete an action.

await a_delete_action(action_id=action_id)

new_actions = await a_list_actions()
action_ids = [action.action_id for action in new_actions]
pytest.assume(action_id not in action_ids)
new_nums = len(new_actions)
pytest.assume(new_nums == old_nums - 1 - index)




if index == old_nums - 1:
new_actions = await a_list_actions()
new_nums = len(new_actions)
pytest.assume(new_nums == 0)
20 changes: 8 additions & 12 deletions test/testcase/test_sync/test_sync_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,10 @@ def test_delete_assistant(self):
delete_assistant(assistant_id=str(assistant_id))

# List assistants.

new_assistants = list_assistants()
assistant_ids = [j.assistant_id for j in new_assistants]
pytest.assume(assistant_id not in assistant_ids)
new_nums = len(new_assistants)
pytest.assume(new_nums == old_nums - 1 - i)
if i == old_nums-1:
new_assistants = list_assistants()
new_nums = len(new_assistants)
pytest.assume(new_nums == 0)


@pytest.mark.test_sync
Expand Down Expand Up @@ -195,12 +193,10 @@ def test_delete_chat(self, assistant_id):
delete_chat(assistant_id=assistant_id, chat_id=str(chat_id))

# List chats.

new_chats = list_chats(assistant_id=assistant_id)
chat_ids = [i.chat_id for i in new_chats]
pytest.assume(chat_id not in chat_ids)
new_nums = len(new_chats)
pytest.assume(new_nums == old_nums - 1 - index)
if index == old_nums-1:
new_chats = list_chats(assistant_id=assistant_id)
new_nums = len(new_chats)
pytest.assume(new_nums == 0)


@pytest.mark.test_sync
Expand Down
33 changes: 14 additions & 19 deletions test/testcase/test_sync/test_sync_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,13 @@ def test_delete_collection(self):
# Delete a collection.

delete_collection(collection_id=collection_id)
if index == old_nums-1:
new_collections = list_collections(order="desc", limit=100, after=None, before=None)

new_collections = list_collections(order="desc", limit=100, after=None, before=None)
# List collections.

# List collections.

collection_ids = [collection.collection_id for collection in new_collections]
pytest.assume(collection_id not in collection_ids)
new_nums = len(new_collections)
pytest.assume(new_nums == old_nums - 1 - index)
new_nums = len(new_collections)
pytest.assume(new_nums == 0)


@pytest.mark.test_sync
Expand Down Expand Up @@ -229,13 +227,12 @@ def test_delete_record(self, collection_id):
delete_record(collection_id=collection_id, record_id=record_id)

# List records.
if index == old_nums-1:
new_records = list_records(collection_id=collection_id, order="desc", limit=20, after=None,
before=None)

new_records = list_records(collection_id=collection_id, order="desc", limit=20, after=None,
before=None)
record_ids = [record.record_id for record in new_records]
pytest.assume(record_id not in record_ids)
new_nums = len(new_records)
pytest.assume(new_nums == old_nums - 1 - index)
new_nums = len(new_records)
pytest.assume(new_nums == 0)


@pytest.mark.test_sync
Expand Down Expand Up @@ -340,9 +337,7 @@ def test_delete_chunk(self, collection_id):
delete_chunk(collection_id=collection_id, chunk_id=chunk_id)

# List chunks.

new_chunks = list_chunks(collection_id=collection_id)
chunk_ids = [chunk.chunk_id for chunk in new_chunks]
pytest.assume(chunk_id not in chunk_ids)
new_nums = len(new_chunks)
pytest.assume(new_nums == old_nums - 1 - index)
if index == old_nums-1:
new_chunks = list_chunks(collection_id=collection_id)
new_nums = len(new_chunks)
pytest.assume(new_nums == 0)
Loading