Skip to content

Commit

Permalink
[Refactor] upgrading box sdk to >= 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
barduinor committed Sep 23, 2024
1 parent caadc62 commit 76522e9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 137 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import logging
import os
import shutil
from typing import List, Optional, Dict
import logging
from typing import Dict, List, Optional

import requests
from box_sdk_gen import (
AiItemBase,
BoxAPIError,
BoxClient,
File,
ByteStream,
BoxSDKError,
)
from box_sdk_gen.managers.search import (
SearchForContentScope,
ByteStream,
CreateAiAskMode,
File,
SearchForContentContentTypes,
SearchForContentScope,
SearchForContentType,
SearchResults,
)
from box_sdk_gen.managers.ai import CreateAiAskMode, CreateAiAskItems

from llama_index.readers.box.BoxAPI.box_ai_extract_beta import (
AiExtractManager,
CreateAiExtractItems,
)
# from llama_index.readers.box.BoxAPI.box_ai_extract_beta import (
# AiExtractManager,
# CreateAiExtractItems,
# )

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -201,7 +201,7 @@ def get_ai_response_from_box_files(
if individual_document_prompt:
mode = CreateAiAskMode.SINGLE_ITEM_QA
for file in box_files:
ask_item = CreateAiAskItems(file.id)
ask_item = AiItemBase(file.id)
logger.info(f"Getting AI prompt for file: {file.id} {file.name}")

# get the AI prompt for the file
Expand All @@ -220,7 +220,7 @@ def get_ai_response_from_box_files(

else:
mode = CreateAiAskMode.MULTIPLE_ITEM_QA
file_ids = [CreateAiAskItems(file.id) for file in box_files]
file_ids = [AiItemBase(file.id) for file in box_files]

# get the AI prompt for the file
ai_response = box_client.ai.create_ai_ask(
Expand Down Expand Up @@ -353,17 +353,13 @@ def get_files_ai_extract_data(
Raises:
BoxAPIError: If an error occurs while interacting with the Box AI API.
"""
ai_extract_manager = AiExtractManager(
auth=box_client.auth, network_session=box_client.network_session
)

for file in box_files:
ask_item = CreateAiExtractItems(file.id)
ask_item = AiItemBase(file.id)
logger.info(f"Getting AI extracted data for file: {file.id} {file.name}")

# get the AI extracted data for the file
try:
ai_response = ai_extract_manager.create_ai_extract(
ai_response = box_client.ai.create_ai_extract(
prompt=ai_prompt, items=[ask_item]
)
except BoxAPIError as e:
Expand Down Expand Up @@ -484,3 +480,6 @@ def search_files_by_metadata(

# return only files from the entries
return [file for file in search_results.entries if file.type == "file"]

# return only files from the entries
return [file for file in search_results.entries if file.type == "file"]
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ maintainers = [
name = "llama-index-readers-box"
packages = [{include = "llama_index/"}]
readme = "README.md"
version = "0.2.2"
version = "0.2.3"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
box-sdk-gen = ">=1.0.0,<1.5.0"
box-sdk-gen = ">=1.5.0"
llama-index-core = "^0.11.0"

[tool.poetry.group.dev.dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ license = "MIT"
name = "llama-index-tools-box"
packages = [{include = "llama_index/"}]
readme = "README.md"
version = "0.2.1"
version = "0.2.3"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
box-sdk-gen = "^1.1.0"
box-sdk-gen = ">=1.5.0"
llama-index-readers-box = "^0.2.0"
llama-index-agent-openai = "^0.3.0"
llama-index-core = "^0.11.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pytest
import openai
import pytest
from box_sdk_gen import BoxClient

from llama_index.tools.box import BoxAIExtractToolSpec
from llama_index.agent.openai import OpenAIAgent
from llama_index.tools.box import BoxAIExtractToolSpec

from tests.conftest import get_testing_data

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import pytest
from box_sdk_gen import BoxClient

from llama_index.tools.box import BoxAIPromptToolSpec
from llama_index.agent.openai import OpenAIAgent

from llama_index.tools.box import BoxAIPromptToolSpec
from tests.conftest import get_testing_data


Expand Down

0 comments on commit 76522e9

Please sign in to comment.