浏览代码

fix: merge

周玉环 1 周之前
父节点
当前提交
82821466c8

+ 1 - 1
xinkeaboard-gemini-langgraph_prompt/Makefile

@@ -8,7 +8,7 @@ help:
 
 dev-backend:
 	@echo "Starting backend development server..."
-	@cd backend && langgraph dev
+	@cd backend && langgraph dev --host 0.0.0.0 --port 8007
 
 # Run frontend and backend concurrently
 dev:

+ 1 - 0
xinkeaboard-gemini-langgraph_prompt/backend/pyproject.toml

@@ -18,6 +18,7 @@ dependencies = [
     "langgraph-api",
     "fastapi",
     "google-genai",
+    "langchain-google-vertexai"
 ]
 
 

+ 11 - 3
xinkeaboard-gemini-langgraph_prompt/backend/src/agent/app.py

@@ -30,6 +30,7 @@ class ResearchResponse(BaseModel):
 class TranslationRequest(BaseModel):
     """Request model for the translation endpoint."""
     text: str
+    model_name: str
 
 
 class TranslationResponse(BaseModel):
@@ -95,7 +96,7 @@ async def translate(request: TranslationRequest):
     """
     # Initialize ChatVertexAI
     llm = ChatVertexAI(
-        model_name="gemini-2.0-flash",
+        model_name=request.model_name,
         temperature=0,
         max_retries=2,
         project=os.getenv("GOOGLE_CLOUD_PROJECT"),  # 必填
@@ -103,8 +104,15 @@ async def translate(request: TranslationRequest):
     )
     
     # Create translation prompt
-    prompt = f"Translate the following text to English:\n\n{request.text}\n\nTranslation:"
-    
+    prompt = f"""你是一名跨境电商本地化专家。请根据用户输入的设备/商品名称及其描述(可选),准确提供出该设备/商品的英文名称。
+            要求如下:
+            1. **准确性 & 本地化**:提供符合目标市场(英语国家)消费者和电商平台习惯的标准名称,避免简单直译。
+            2. **可搜索性**:提供的英文名称应是在主流电商平台(如Amazon, eBay)或专业网站上能精确检索到该商品/类目的常用名称。
+            3. **输出格式**:*仅*输出一个有效的JSON对象,格式为:{{"English_names": array<string> }}。
+            4. **数量**:`english_names`数组包含1个或多个最常用的英文名称。
+            5. **用户输入**:{request.text}
+            **重要指令**:禁止包含任何JSON之外的内容(如解释、评论、额外文本)。用户输入紧随此提示。
+            """
     # Run the translation
     result = await asyncio.get_event_loop().run_in_executor(
         None,