Skip to content

Commit

Permalink
Fix variable typo (langgenius#8084)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuzooVn authored and lau-td committed Oct 23, 2024
1 parent 9350c44 commit 954e47f
Show file tree
Hide file tree
Showing 215 changed files with 599 additions and 597 deletions.
4 changes: 2 additions & 2 deletions api/configs/feature/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CodeExecutionSandboxConfig(BaseSettings):
"""

CODE_EXECUTION_ENDPOINT: HttpUrl = Field(
description="endpoint URL of code execution servcie",
description="endpoint URL of code execution service",
default="http://sandbox:8194",
)

Expand Down Expand Up @@ -415,7 +415,7 @@ class MailConfig(BaseSettings):
"""

MAIL_TYPE: Optional[str] = Field(
description="Mail provider type name, default to None, availabile values are `smtp` and `resend`.",
description="Mail provider type name, default to None, available values are `smtp` and `resend`.",
default=None,
)

Expand Down
14 changes: 7 additions & 7 deletions api/constants/recommended_apps.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/controllers/console/datasets/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from core.provider_manager import ProviderManager
from core.rag.datasource.vdb.vector_type import VectorType
from core.rag.extractor.entity.extract_setting import ExtractSetting
from core.rag.retrieval.retrival_methods import RetrievalMethod
from core.rag.retrieval.retrieval_methods import RetrievalMethod
from extensions.ext_database import db
from fields.app_fields import related_app_list
from fields.dataset_fields import dataset_detail_fields, dataset_query_detail_fields
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/service_api/dataset/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def post(self, tenant_id, dataset_id, document_id):
segments = SegmentService.multi_create_segment(args["segments"], document, dataset)
return {"data": marshal(segments, segment_fields), "doc_form": document.doc_form}, 200
else:
return {"error": "Segemtns is required"}, 400
return {"error": "Segments is required"}, 400

def get(self, tenant_id, dataset_id, document_id):
"""Create single segment."""
Expand Down
2 changes: 1 addition & 1 deletion api/core/helper/position_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def is_filtered(
name_func: Callable[[Any], str],
) -> bool:
"""
Chcek if the object should be filtered out.
Check if the object should be filtered out.
Overall logic: exclude > include > pin
:param include_set: the set of names to be included
:param exclude_set: the set of names to be excluded
Expand Down
2 changes: 1 addition & 1 deletion api/core/indexing_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def _split_to_documents(self, text_docs: list[Document], splitter: TextSplitter,
hash = helper.generate_text_hash(document_node.page_content)
document_node.metadata['doc_id'] = doc_id
document_node.metadata['doc_hash'] = hash
# delete Spliter character
# delete Splitter character
page_content = document_node.page_content
if page_content.startswith(".") or page_content.startswith("。"):
page_content = page_content[1:]
Expand Down
2 changes: 1 addition & 1 deletion api/core/llm_generator/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
{{TASK_DESCRIPTION}}
</task_description>
Based on task description, please create a well-structured prompt template that another AI could use to consistently complete the task. The prompt template should include:
- Do not inlcude <input> or <output> section and variables in the prompt, assume user will add them at their own will.
- Do not include <input> or <output> section and variables in the prompt, assume user will add them at their own will.
- Clear instructions for the AI that will be using this prompt, demarcated with <instructions> tags. The instructions should provide step-by-step directions on how to complete the task using the input variables. Also Specifies in the instructions that the output should not contain any xml tag.
- Relevant examples if needed to clarify the task further, demarcated with <example> tags. Do not include variables in the prompt. Give three pairs of input and output examples.
- Include other relevant sections demarcated with appropriate XML tags like <examples>, <instructions>.
Expand Down
4 changes: 2 additions & 2 deletions api/core/model_runtime/docs/en_US/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
- `mode` (string) voice model.(available for model type `tts`
- `name` (string) voice model display name.(available for model type `tts`
- `language` (string) the voice model supports languages.(available for model type `tts`
- `word_limit` (int) Single conversion word limit, paragraphwise by default(available for model type `tts`
- `word_limit` (int) Single conversion word limit, paragraph-wise by default(available for model type `tts`
- `audio_type` (string) Support audio file extension format, e.g.:mp3,wav(available for model type `tts`
- `max_workers` (int) Number of concurrent workers supporting text and audio conversion(available for model type`tts`
- `max_characters_per_chunk` (int) Maximum characters per chunk (available for model type `moderation`)
Expand Down Expand Up @@ -150,7 +150,7 @@

- `input` (float) Input price, i.e., Prompt price
- `output` (float) Output price, i.e., returned content price
- `unit` (float) Pricing unit, e.g., if the price is meausred in 1M tokens, the corresponding token amount for the unit price is `0.000001`.
- `unit` (float) Pricing unit, e.g., if the price is measured in 1M tokens, the corresponding token amount for the unit price is `0.000001`.
- `currency` (string) Currency unit

### ProviderCredentialSchema
Expand Down
2 changes: 1 addition & 1 deletion api/core/model_runtime/model_providers/__base/tts_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class TTSModel(AIModel):
"""
Model class for ttstext model.
Model class for TTS model.
"""
model_type: ModelType = ModelType.TTS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def _chat_generate(self, model: str, credentials: dict,
try:
schema = json.loads(json_schema)
except:
raise ValueError(f"not currect json_schema format: {json_schema}")
raise ValueError(f"not correct json_schema format: {json_schema}")
model_parameters.pop("json_schema")
model_parameters["response_format"] = {"type": "json_schema", "json_schema": schema}
else:
Expand Down
2 changes: 1 addition & 1 deletion api/core/model_runtime/model_providers/baichuan/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
)


class BaichuanLarguageModel(LargeLanguageModel):
class BaichuanLanguageModel(LargeLanguageModel):

def _invoke(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _invoke(self, model: str, credentials: dict,
token_usage = 0

for chunk in chunks:
# embeding chunk
# embedding chunk
chunk_embeddings, chunk_usage = self.embedding(
model=model,
api_key=api_key,
Expand Down
6 changes: 3 additions & 3 deletions api/core/model_runtime/model_providers/bedrock/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,11 +793,11 @@ def _handle_generate_stream_response(self, model: str, credentials: dict, respon
def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]:
"""
Map model invoke error to unified error
The key is the ermd = genai.GenerativeModel(model)ror type thrown to the caller
The value is the md = genai.GenerativeModel(model)error type thrown by the model,
The key is the ermd = genai.GenerativeModel(model) error type thrown to the caller
The value is the md = genai.GenerativeModel(model) error type thrown by the model,
which needs to be converted into a unified error type for the caller.
:return: Invoke emd = genai.GenerativeModel(model)rror mapping
:return: Invoke emd = genai.GenerativeModel(model) error mapping
"""
return {
InvokeConnectionError: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ def validate_credentials(self, model: str, credentials: dict) -> None:
def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]:
"""
Map model invoke error to unified error
The key is the ermd = genai.GenerativeModel(model)ror type thrown to the caller
The value is the md = genai.GenerativeModel(model)error type thrown by the model,
The key is the ermd = genai.GenerativeModel(model) error type thrown to the caller
The value is the md = genai.GenerativeModel(model) error type thrown by the model,
which needs to be converted into a unified error type for the caller.
:return: Invoke emd = genai.GenerativeModel(model)rror mapping
:return: Invoke emd = genai.GenerativeModel(model) error mapping
"""
return {
InvokeConnectionError: [],
Expand Down
6 changes: 3 additions & 3 deletions api/core/model_runtime/model_providers/google/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,11 @@ def _format_message_to_glm_content(self, message: PromptMessage) -> ContentType:
def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]:
"""
Map model invoke error to unified error
The key is the ermd = genai.GenerativeModel(model)ror type thrown to the caller
The value is the md = genai.GenerativeModel(model)error type thrown by the model,
The key is the ermd = genai.GenerativeModel(model) error type thrown to the caller
The value is the md = genai.GenerativeModel(model) error type thrown by the model,
which needs to be converted into a unified error type for the caller.
:return: Invoke emd = genai.GenerativeModel(model)rror mapping
:return: Invoke emd = genai.GenerativeModel(model) error mapping
"""
return {
InvokeConnectionError: [
Expand Down
2 changes: 1 addition & 1 deletion api/core/model_runtime/model_providers/minimax/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _num_tokens_from_messages(self, messages: list[PromptMessage], tools: list[P
Calculate num tokens for minimax model
not like ChatGLM, Minimax has a special prompt structure, we could not find a proper way
to caculate the num tokens, so we use str() to convert the prompt to string
to calculate the num tokens, so we use str() to convert the prompt to string
Minimax does not provide their own tokenizer of adab5.5 and abab5 model
therefore, we use gpt2 tokenizer instead
Expand Down
1 change: 1 addition & 0 deletions api/core/model_runtime/model_providers/novita/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class NovitaLargeLanguageModel(OAIAPICompatLargeLanguageModel):

def _update_endpoint_url(self, credentials: dict):

credentials['endpoint_url'] = "https://api.novita.ai/v3/openai"
credentials['extra_headers'] = { 'X-Novita-Source': 'dify.ai' }
return credentials
Expand Down
8 changes: 4 additions & 4 deletions api/core/model_runtime/model_providers/oci/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def _generate(self, model: str, credentials: dict,
request_args["compartmentId"] = compartment_id
request_args["servingMode"]["modelId"] = model

chathistory = []
chat_history = []
system_prompts = []
#if "meta.llama" in model:
# request_args["chatRequest"]["apiFormat"] = "GENERIC"
Expand Down Expand Up @@ -273,16 +273,16 @@ def _generate(self, model: str, credentials: dict,
if isinstance(message.content, str):
text = message.content
if isinstance(message, UserPromptMessage):
chathistory.append({"role": "USER", "message": text})
chat_history.append({"role": "USER", "message": text})
else:
chathistory.append({"role": "CHATBOT", "message": text})
chat_history.append({"role": "CHATBOT", "message": text})
if isinstance(message, SystemPromptMessage):
if isinstance(message.content, str):
system_prompts.append(message.content)
args = {"apiFormat": "COHERE",
"preambleOverride": ' '.join(system_prompts),
"message": prompt_messages[-1].content,
"chatHistory": chathistory, }
"chatHistory": chat_history, }
request_args["chatRequest"].update(args)
elif model.startswith("meta"):
#print("run meta " * 10)
Expand Down
2 changes: 1 addition & 1 deletion api/core/model_runtime/model_providers/openai/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def _chat_generate(self, model: str, credentials: dict,
try:
schema = json.loads(json_schema)
except:
raise ValueError(f"not currect json_schema format: {json_schema}")
raise ValueError(f"not correct json_schema format: {json_schema}")
model_parameters.pop("json_schema")
model_parameters["response_format"] = {"type": "json_schema", "json_schema": schema}
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def set_reinforce_hotword(self, reinforce_hotword):

class FlashRecognizer:
"""
reponse:
response:
request_id string
status Integer
message String
Expand Down Expand Up @@ -132,9 +132,9 @@ def _build_req_with_signature(self, secret_key, params, header):
signstr = self._format_sign_string(query)
signature = self._sign(signstr, secret_key)
header["Authorization"] = signature
requrl = "https://"
requrl += signstr[4::]
return requrl
req_url = "https://"
req_url += signstr[4::]
return req_url

def _create_query_arr(self, req):
return {
Expand Down
6 changes: 3 additions & 3 deletions api/core/model_runtime/model_providers/vertex_ai/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,11 @@ def _format_message_to_glm_content(self, message: PromptMessage) -> glm.Content:
def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]:
"""
Map model invoke error to unified error
The key is the ermd = gml.GenerativeModel(model)ror type thrown to the caller
The value is the md = gml.GenerativeModel(model)error type thrown by the model,
The key is the ermd = gml.GenerativeModel(model) error type thrown to the caller
The value is the md = gml.GenerativeModel(model) error type thrown by the model,
which needs to be converted into a unified error type for the caller.
:return: Invoke emd = gml.GenerativeModel(model)rror mapping
:return: Invoke emd = gml.GenerativeModel(model) error mapping
"""
return {
InvokeConnectionError: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ def _prepare_request(
**kwargs,
)

def _object_to_formfata(self, key: str, value: Data | Mapping[object, object]) -> list[tuple[str, str]]:
def _object_to_formdata(self, key: str, value: Data | Mapping[object, object]) -> list[tuple[str, str]]:
items = []

if isinstance(value, Mapping):
for k, v in value.items():
items.extend(self._object_to_formfata(f"{key}[{k}]", v))
items.extend(self._object_to_formdata(f"{key}[{k}]", v))
return items
if isinstance(value, list | tuple):
for v in value:
items.extend(self._object_to_formfata(key + "[]", v))
items.extend(self._object_to_formdata(key + "[]", v))
return items

def _primitive_value_to_str(val) -> str:
Expand All @@ -165,7 +165,7 @@ def _primitive_value_to_str(val) -> str:

def _make_multipartform(self, data: Mapping[object, object]) -> dict[str, object]:

items = flatten([self._object_to_formfata(k, v) for k, v in data.items()])
items = flatten([self._object_to_formdata(k, v) for k, v in data.items()])

serialized: dict[str, object] = {}
for key, value in items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ def clean(self, content) -> str:
"""clean document content."""
from unstructured.cleaners.core import clean_non_ascii_chars

# Returns "This text containsnon-ascii characters!"
# Returns "This text contains non-ascii characters!"
return clean_non_ascii_chars(content)
Loading

0 comments on commit 954e47f

Please sign in to comment.