Skip to content

Commit

Permalink
Merge branch 'main' into feat/external-knowledge-api
Browse files Browse the repository at this point in the history
# Conflicts:
#	api/poetry.lock
#	web/service/datasets.ts
  • Loading branch information
JohnJyong committed Sep 30, 2024
2 parents 6f9d6cd + 77aef9f commit 77bfb9e
Show file tree
Hide file tree
Showing 108 changed files with 2,539 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
with:
images: ${{ env[matrix.image_name_env] }}
tags: |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-') }}
type=ref,event=branch
type=sha,enable=true,priority=100,prefix=,suffix=,format=long
type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
Expand Down
3 changes: 2 additions & 1 deletion api/controllers/console/datasets/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,10 @@ def get(self):
case (
VectorType.MILVUS
| VectorType.RELYT
| VectorType.PGVECTOR
| VectorType.TIDB_VECTOR
| VectorType.CHROMA
| VectorType.TENCENT
| VectorType.PGVECTO_RS
):
return {"retrieval_method": [RetrievalMethod.SEMANTIC_SEARCH.value]}
case (
Expand All @@ -627,6 +627,7 @@ def get(self):
| VectorType.MYSCALE
| VectorType.ORACLE
| VectorType.ELASTICSEARCH
| VectorType.PGVECTOR
):
return {
"retrieval_method": [
Expand Down
6 changes: 4 additions & 2 deletions api/controllers/console/datasets/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class WebsiteCrawlApi(Resource):
@account_initialization_required
def post(self):
parser = reqparse.RequestParser()
parser.add_argument("provider", type=str, choices=["firecrawl"], required=True, nullable=True, location="json")
parser.add_argument(
"provider", type=str, choices=["firecrawl", "jinareader"], required=True, nullable=True, location="json"
)
parser.add_argument("url", type=str, required=True, nullable=True, location="json")
parser.add_argument("options", type=dict, required=True, nullable=True, location="json")
args = parser.parse_args()
Expand All @@ -33,7 +35,7 @@ class WebsiteCrawlStatusApi(Resource):
@account_initialization_required
def get(self, job_id: str):
parser = reqparse.RequestParser()
parser.add_argument("provider", type=str, choices=["firecrawl"], required=True, location="args")
parser.add_argument("provider", type=str, choices=["firecrawl", "jinareader"], required=True, location="args")
args = parser.parse_args()
# get crawl status
try:
Expand Down
49 changes: 45 additions & 4 deletions api/controllers/console/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,52 @@ def get(self):
return result

content = json.loads(response.content)
result["version"] = content["version"]
result["release_date"] = content["releaseDate"]
result["release_notes"] = content["releaseNotes"]
result["can_auto_update"] = content["canAutoUpdate"]
if _has_new_version(latest_version=content["version"], current_version=f"{args.get('current_version')}"):
result["version"] = content["version"]
result["release_date"] = content["releaseDate"]
result["release_notes"] = content["releaseNotes"]
result["can_auto_update"] = content["canAutoUpdate"]
return result


def _has_new_version(*, latest_version: str, current_version: str) -> bool:
def parse_version(version: str) -> tuple:
# Split version into parts and pre-release suffix if any
parts = version.split("-")
version_parts = parts[0].split(".")
pre_release = parts[1] if len(parts) > 1 else None

# Validate version format
if len(version_parts) != 3:
raise ValueError(f"Invalid version format: {version}")

try:
# Convert version parts to integers
major, minor, patch = map(int, version_parts)
return (major, minor, patch, pre_release)
except ValueError:
raise ValueError(f"Invalid version format: {version}")

latest = parse_version(latest_version)
current = parse_version(current_version)

# Compare major, minor, and patch versions
for latest_part, current_part in zip(latest[:3], current[:3]):
if latest_part > current_part:
return True
elif latest_part < current_part:
return False

# If versions are equal, check pre-release suffixes
if latest[3] is None and current[3] is not None:
return True
elif latest[3] is not None and current[3] is None:
return False
elif latest[3] is not None and current[3] is not None:
# Simple string comparison for pre-release versions
return latest[3] > current[3]

return False


api.add_resource(VersionApi, "/version")
3 changes: 2 additions & 1 deletion api/core/app/apps/advanced_chat/generate_task_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ def _wrapper_process_stream_response(
except Exception as e:
logger.error(e)
break
yield MessageAudioEndStreamResponse(audio="", task_id=task_id)
if tts_publisher:
yield MessageAudioEndStreamResponse(audio="", task_id=task_id)

def _process_stream_response(
self,
Expand Down
3 changes: 2 additions & 1 deletion api/core/app/apps/workflow/generate_task_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ def _wrapper_process_stream_response(
except Exception as e:
logger.error(e)
break
yield MessageAudioEndStreamResponse(audio="", task_id=task_id)
if tts_publisher:
yield MessageAudioEndStreamResponse(audio="", task_id=task_id)

def _process_stream_response(
self,
Expand Down
2 changes: 1 addition & 1 deletion api/core/app/segments/exc.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
class VariableError(Exception):
class VariableError(ValueError):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ def _wrapper_process_stream_response(
else:
start_listener_time = time.time()
yield MessageAudioStreamResponse(audio=audio.audio, task_id=task_id)
yield MessageAudioEndStreamResponse(audio="", task_id=task_id)
if publisher:
yield MessageAudioEndStreamResponse(audio="", task_id=task_id)

def _process_stream_response(
self, publisher: AppGeneratorTTSPublisher, trace_manager: Optional[TraceQueueManager] = None
Expand Down
2 changes: 1 addition & 1 deletion api/core/entities/provider_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def get_current_credentials(self, model_type: ModelType, model: str) -> Optional
credentials = model_configuration.credentials
break

if self.custom_configuration.provider:
if not credentials and self.custom_configuration.provider:
credentials = self.custom_configuration.provider.credentials

return credentials
Expand Down
7 changes: 6 additions & 1 deletion api/core/model_runtime/callbacks/base_callback.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from abc import ABC, abstractmethod
from typing import Optional

from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk
Expand All @@ -13,14 +14,15 @@
}


class Callback:
class Callback(ABC):
"""
Base class for callbacks.
Only for LLM.
"""

raise_error: bool = False

@abstractmethod
def on_before_invoke(
self,
llm_instance: AIModel,
Expand Down Expand Up @@ -48,6 +50,7 @@ def on_before_invoke(
"""
raise NotImplementedError()

@abstractmethod
def on_new_chunk(
self,
llm_instance: AIModel,
Expand Down Expand Up @@ -77,6 +80,7 @@ def on_new_chunk(
"""
raise NotImplementedError()

@abstractmethod
def on_after_invoke(
self,
llm_instance: AIModel,
Expand Down Expand Up @@ -106,6 +110,7 @@ def on_after_invoke(
"""
raise NotImplementedError()

@abstractmethod
def on_invoke_error(
self,
llm_instance: AIModel,
Expand Down
Loading

0 comments on commit 77bfb9e

Please sign in to comment.