From deea2bc5e93186df3b3c007ef4ae05b0b167c3e2 Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Thu, 27 Jun 2024 11:03:35 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat=20oss=E6=9B=BF=E6=8D=A2=E4=B8=BAS3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix --- app/service/design/model_process_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/service/design/model_process_service.py b/app/service/design/model_process_service.py index fffbd67..076e04d 100644 --- a/app/service/design/model_process_service.py +++ b/app/service/design/model_process_service.py @@ -13,7 +13,7 @@ def model_transpose(image_path): # new_data = [] for item in data: - if item[0] >= 230 and item[1] >= 230 and item[2] >= 230: + if item[0] >= 256 and item[1] >= 256 and item[2] >= 256: new_data.append((255, 255, 255, 0)) else: new_data.append(item) From 1716dff372640f79e08ab20a1544503c5d815b0c Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Thu, 27 Jun 2024 15:05:36 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat=20=E4=BF=AE=E5=A4=8D=E6=B8=90=E5=8F=98?= =?UTF-8?q?=E8=89=B2=E9=80=9A=E9=81=93=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix --- app/core/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/core/config.py b/app/core/config.py index 9e89e47..cfc04f5 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -19,7 +19,7 @@ class Settings(BaseSettings): LOGGING_CONFIG_FILE = os.path.join(BASE_DIR, 'logging_env.py') -OSS = "S3" +OSS = "minio" DEBUG = False if DEBUG: LOGS_PATH = "logs/" From a18d423d062ba5f7943ed834436f96ffc88140fc Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Fri, 28 Jun 2024 11:11:55 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat=20fix=20redis=20host=20=E6=9B=B4?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/core/config.py b/app/core/config.py index cfc04f5..09e48fc 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -48,7 +48,7 @@ S3_AWS_SECRET_ACCESS_KEY = "LNIwFFB27/QedtZ+Q/viVUoX9F5x1DbuM8N0DkD8" S3_REGION_NAME = "ap-east-1" # redis 配置 -REDIS_HOST = "10.1.1.150" +REDIS_HOST = "10.1.1.240" REDIS_PORT = "6379" REDIS_DB = "2" From d772adcd7a13da83b7de8f04d7197f612736fb5f Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Fri, 28 Jun 2024 13:59:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat=20fix=20redis=20host=20=E6=9B=B4?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatgpt_for_translation.py | 59 +++++++++++-------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/app/service/prompt_generation/chatgpt_for_translation.py b/app/service/prompt_generation/chatgpt_for_translation.py index 71d6e4f..4ade635 100644 --- a/app/service/prompt_generation/chatgpt_for_translation.py +++ b/app/service/prompt_generation/chatgpt_for_translation.py @@ -1,9 +1,8 @@ -import os +import logging from langchain.chains import LLMChain from langchain.chat_models import ChatOpenAI -from langchain_core.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate, ChatPromptTemplate, \ - PromptTemplate +from langchain_core.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate, ChatPromptTemplate from app.core.config import OPENAI_MODEL, OPENAI_API_KEY @@ -21,7 +20,8 @@ def translate_to_en(text): """You are a translation expert, proficient in various languages. And can translate various languages into English. Please translate to grammatically correct English regardless of the input language. - If the input is in English or numbers, check for grammatical errors. If there are no errors, output the input directly. + If the input is already in English, or consists of letters or numbers such as "cat", "abc", or "1", + output the input text exactly as it is without any modifications or additions. If there are grammatical errors, correct them and then output the sentence.""" ) system_message_prompt = SystemMessagePromptTemplate.from_template(template) @@ -36,34 +36,41 @@ def translate_to_en(text): ) translate_chain = LLMChain(llm=llm, prompt=chat_prompt_template) - template = ( - """ - Input sentence: - {translate} - 1. Based on the input,adjust the input sentence to make it more suitable for prompts for generating images, - ensuring all key nouns or adjectives related to the image are retained. - 2. Simplify complex sentence structures and clarify ambiguous expressions. - 3. Only Output the adjusted English sentence. + result = translate_chain.invoke(text) - Output : - """ - ) - # "Based on the input sentence, extract key adjectives and nouns.Only Output extracted key words." - # 1. Check if the input sentence contains any grammatical errors. If there are errors, please correct them before proceeding. + logging.info("translate result : " + result.get('text')) + # print("translate result : " + result.get('text')) + return result.get('text') - prompt_template = PromptTemplate(input_variables=["translate"], template=template) - prompt_chain = LLMChain(llm=llm, prompt=prompt_template) - - from langchain.chains import SimpleSequentialChain - overall_chain = SimpleSequentialChain(chains=[translate_chain, prompt_chain], verbose=True) - - response = overall_chain.run(text) - return response + # template = ( + # """ + # Input sentence: + # {translate} + # 1. Based on the input,adjust the input sentence to make it more suitable for prompts for generating images, + # ensuring all key nouns or adjectives related to the image are retained. + # 2. Simplify complex sentence structures and clarify ambiguous expressions. + # 3. Only Output the adjusted English sentence. + # + # Output : + # """ + # ) + # # "Based on the input sentence, extract key adjectives and nouns.Only Output extracted key words." + # # 1. Check if the input sentence contains any grammatical errors. If there are errors, please correct them before proceeding. + # + # prompt_template = PromptTemplate(input_variables=["translate"], template=template) + # prompt_chain = LLMChain(llm=llm, prompt=prompt_template) + # + # from langchain.chains import SimpleSequentialChain + # overall_chain = SimpleSequentialChain(chains=[translate_chain, prompt_chain], verbose=True) + # + # response = overall_chain.run(text) + # return response def main(): """Main function""" - translate_to_en("生成一件运动风格的夹克,带有拉链和口袋,适合休闲穿着") + text = translate_to_en("fire") + print(text) if __name__ == "__main__":