Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Internationalization of Models #2068

Merged
merged 1 commit into from
Jan 22, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from django.db.models import QuerySet
from django.http import StreamingHttpResponse
from django.utils.translation import gettext as __
from django.utils.translation import gettext as _
from langchain.chat_models.base import BaseChatModel
from langchain.schema import BaseMessage
from langchain.schema.messages import HumanMessage, AIMessage
Expand Down Expand Up @@ -174,7 +174,7 @@ def get_stream_result(message_list: List[BaseMessage],
[AIMessageChunk(content=no_references_setting.get('value').replace('{question}', problem_text))]), False
if chat_model is None:
return iter([AIMessageChunk(
__('Sorry, the AI model is not configured. Please go to the application to set up the AI model first.'))]), False
_('Sorry, the AI model is not configured. Please go to the application to set up the AI model first.'))]), False
else:
return chat_model.stream(message_list), True

Expand Down Expand Up @@ -219,7 +219,7 @@ def get_block_result(message_list: List[BaseMessage],
return AIMessage(no_references_setting.get('value').replace('{question}', problem_text)), False
if chat_model is None:
return AIMessage(
__('Sorry, the AI model is not configured. Please go to the application to set up the AI model first.')), False
_('Sorry, the AI model is not configured. Please go to the application to set up the AI model first.')), False
else:
return chat_model.invoke(message_list), True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"""
from typing import List

from django.utils.translation import gettext as __
from django.utils.translation import gettext as _
from langchain.schema import HumanMessage

from application.chat_pipeline.step.reset_problem_step.i_reset_problem_step import IResetProblemStep
from application.models import ChatRecord
from common.util.split_model import flat_map
from setting.models_provider.tools import get_model_instance_by_model_user_id

prompt = __(
prompt = _(
"() contains the user's question. Answer the guessed user's question based on the context ({question}) Requirement: Output a complete question and put it in the <data></data> tag")


Expand Down
Loading
Loading