Compare commits

...

4 Commits

Author SHA1 Message Date
Marcus Schiesser 5b31035659 fix: remove E402 check for some files 2024-08-14 17:42:54 +07:00
Marcus Schiesser c5e85656ad feat: add ruff to github action 2024-08-14 17:22:10 +07:00
Marcus Schiesser cd0da1dc12 fix: ruff --fix 2024-08-14 17:13:08 +07:00
Marcus Schiesser ee251a725a fix: formatting 2024-08-14 17:12:27 +07:00
18 changed files with 31 additions and 20 deletions
@@ -30,3 +30,13 @@ jobs:
- name: Run Prettier
run: pnpm run format
- name: Run Python format check
uses: chartboost/ruff-action@v1
with:
args: "format --check"
- name: Run Python lint
uses: chartboost/ruff-action@v1
with:
args: "check"
@@ -1,8 +1,6 @@
import os
import yaml
import json
import importlib
from cachetools import cached, LRUCache
from llama_index.core.tools.tool_spec.base import BaseToolSpec
from llama_index.core.tools.function_tool import FunctionTool
@@ -13,7 +11,6 @@ class ToolType:
class ToolFactory:
TOOL_SOURCE_PACKAGE_MAP = {
ToolType.LLAMAHUB: "llama_index.tools",
ToolType.LOCAL: "app.engine.tools",
@@ -3,7 +3,7 @@ import logging
import base64
import uuid
from pydantic import BaseModel
from typing import List, Tuple, Dict, Optional
from typing import List, Dict, Optional
from llama_index.core.tools import FunctionTool
from e2b_code_interpreter import CodeInterpreter
from e2b_code_interpreter.models import Logs
@@ -26,7 +26,6 @@ class E2BToolOutput(BaseModel):
class E2BCodeInterpreter:
output_dir = "output/tool"
def __init__(self, api_key: str = None):
+1 -3
View File
@@ -1,8 +1,6 @@
import os
import logging
from typing import List
from pydantic import BaseModel, validator
from llama_index.core.indices.vector_store import VectorStoreIndex
from pydantic import BaseModel
logger = logging.getLogger(__name__)
@@ -1,5 +1,3 @@
import os
import json
from pydantic import BaseModel, Field
@@ -6,11 +6,13 @@ import os
DEFAULT_MODEL = "gpt-3.5-turbo"
DEFAULT_EMBEDDING_MODEL = "text-embedding-3-large"
class TSIEmbedding(OpenAIEmbedding):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self._query_engine = self._text_engine = self.model_name
def llm_config_from_env() -> Dict:
from llama_index.core.constants import DEFAULT_TEMPERATURE
@@ -32,7 +34,7 @@ def llm_config_from_env() -> Dict:
def embedding_config_from_env() -> Dict:
from llama_index.core.constants import DEFAULT_EMBEDDING_DIM
model = os.getenv("EMBEDDING_MODEL", DEFAULT_EMBEDDING_MODEL)
dimension = os.getenv("EMBEDDING_DIM", DEFAULT_EMBEDDING_DIM)
api_key = os.getenv("T_SYSTEMS_LLMHUB_API_KEY")
@@ -46,6 +48,7 @@ def embedding_config_from_env() -> Dict:
}
return config
def init_llmhub():
from llama_index.llms.openai_like import OpenAILike
@@ -58,4 +61,4 @@ def init_llmhub():
is_chat_model=True,
is_function_calling_model=False,
context_window=4096,
)
)
@@ -1,3 +1,4 @@
# flake8: noqa: E402
from dotenv import load_dotenv
from app.engine.index import get_index
@@ -1,3 +1,4 @@
# flake8: noqa: E402
from dotenv import load_dotenv
load_dotenv()
@@ -17,9 +17,11 @@ def _create_weaviate_client():
client = weaviate.connect_to_weaviate_cloud(cluster_url, auth_credentials)
return client
# Global variable to store the Weaviate client
client = None
def get_vector_store():
global client
if client is None:
@@ -1,3 +1,4 @@
# flake8: noqa: E402
from dotenv import load_dotenv
load_dotenv()
@@ -5,4 +5,4 @@ def load_from_env(var: str, throw_error: bool = True) -> str:
res = os.getenv(var)
if res is None and throw_error:
raise ValueError(f"Missing environment variable: {var}")
return res
return res
@@ -1,3 +1,4 @@
# flake8: noqa: E402
from dotenv import load_dotenv
from app.settings import init_settings
@@ -1,6 +1,6 @@
import logging
import os
from typing import Any, Dict, List, Literal, Optional, Set
from typing import Any, Dict, List, Literal, Optional
from llama_index.core.llms import ChatMessage, MessageRole
from llama_index.core.schema import NodeWithScore
@@ -21,7 +21,9 @@ class FileUploadRequest(BaseModel):
def upload_file(request: FileUploadRequest) -> List[str]:
try:
logger.info("Processing file")
return PrivateFileService.process_file(request.filename, request.base64, request.params)
return PrivateFileService.process_file(
request.filename, request.base64, request.params
)
except Exception as e:
logger.error(f"Error processing file: {e}", exc_info=True)
raise HTTPException(status_code=500, detail="Error processing file")
@@ -3,8 +3,7 @@ import mimetypes
import os
from io import BytesIO
from pathlib import Path
import time
from typing import Any, Dict, List, Tuple
from typing import Any, List, Tuple
from uuid import uuid4
@@ -14,7 +13,6 @@ from llama_index.core.ingestion import IngestionPipeline
from llama_index.core.readers.file.base import (
_try_loading_included_file_formats as get_file_loaders_map,
)
from llama_index.core.readers.file.base import default_file_metadata_func
from llama_index.core.schema import Document
from llama_index.indices.managed.llama_cloud.base import LlamaCloudIndex
from llama_index.readers.file import FlatReader
@@ -25,7 +25,6 @@ class NextQuestions(BaseModel):
class NextQuestionSuggestion:
@staticmethod
async def suggest_next_questions(
messages: List[Message],
@@ -1,3 +1,4 @@
# flake8: noqa: E402
from dotenv import load_dotenv
load_dotenv()
@@ -21,7 +22,6 @@ STORAGE_DIR = os.getenv("STORAGE_DIR", "storage")
def get_doc_store():
# If the storage directory is there, load the document store from it.
# If not, set up an in-memory document store since we can't load from a directory that doesn't exist.
if os.path.exists(STORAGE_DIR):
@@ -1,3 +1,4 @@
# flake8: noqa: E402
from dotenv import load_dotenv
load_dotenv()