Skip to content

Commit fd71d90

Browse files
chore: include unrelated workspace edits (prompts/uv.lock/middleware)
1 parent ef50d44 commit fd71d90

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

api/core/llm_generator/prompts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
- The title must be natural, friendly, and in the same language as the input.
1212
- If the input is a direct question to the model, you may add an emoji at the end.
1313
14+
- Special Note for Persian (Farsi): If the input is Persian (Farsi), ALWAYS generate the title in Persian (Farsi). Use Persian characters (for example: پ، چ، ژ، گ، ک، ی) and ensure the "Language Type" field is "Persian" or "Farsi". Do NOT use Arabic or any other language or script when the input is Persian.
15+
1416
3. Output Format
1517
Return **only** a valid JSON object with these exact keys and no additional text:
1618
{
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import json
2+
from unittest.mock import MagicMock, patch
3+
4+
from core.llm_generator.llm_generator import LLMGenerator
5+
6+
7+
class DummyMessage:
8+
def __init__(self, content):
9+
self.content = content
10+
11+
12+
class DummyResponse:
13+
def __init__(self, content):
14+
self.message = DummyMessage(content)
15+
16+
17+
def make_json_response(language, output):
18+
return json.dumps({"Language Type": language, "Your Reasoning": "...", "Your Output": output})
19+
20+
21+
@patch("core.llm_generator.llm_generator.ModelManager.get_default_model_instance")
22+
def test_generate_conversation_name_enforces_persian(mock_get_model):
23+
# A Persian input containing Persian-specific character 'پ'
24+
persian_query = "سلام، چطوری؟ پ" # contains 'پ'
25+
26+
# First model response: misdetected as Arabic and returns Arabic title
27+
first_resp = DummyResponse(make_json_response("Arabic", "مرحبا"))
28+
# Second response (after retry): returns a Persian title with Persian-specific chars
29+
second_resp = DummyResponse(make_json_response("Persian", "عنوان پِرس"))
30+
31+
model_instance = MagicMock()
32+
model_instance.invoke_llm.side_effect = [first_resp, second_resp]
33+
34+
mock_get_model.return_value = model_instance
35+
36+
name = LLMGenerator.generate_conversation_name("tenant1", persian_query)
37+
38+
# The final name should come from the Persian response (contains Persian-specific char 'پ')
39+
assert "پ" in name
40+
# Ensure the model was invoked at least twice (retry occurred)
41+
assert model_instance.invoke_llm.call_count >= 2
42+
43+
44+
@patch("core.llm_generator.llm_generator.ModelManager.get_default_model_instance")
45+
def test_generate_conversation_name_translation_fallback(mock_get_model):
46+
# Persian query
47+
persian_query = "این یک تست است پ"
48+
49+
# Model returns non-Persian outputs consistently
50+
non_persian_resp = DummyResponse(make_json_response("Arabic", "مرحبا"))
51+
52+
# Translate response (last call) returns Persian translation
53+
translate_resp = DummyResponse("عنوان ترجمه شده پ")
54+
55+
model_instance = MagicMock()
56+
# First two calls return non-persian results; third call is translation
57+
model_instance.invoke_llm.side_effect = [non_persian_resp, non_persian_resp, translate_resp]
58+
59+
mock_get_model.return_value = model_instance
60+
61+
name = LLMGenerator.generate_conversation_name("tenant1", persian_query)
62+
63+
# Final name should contain Persian character 'پ' from translation fallback
64+
assert "پ" in name
65+
assert model_instance.invoke_llm.call_count >= 3

api/uv.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker/docker-compose.middleware.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ services:
176176
THIRD_PARTY_SIGNATURE_VERIFICATION_ENABLED: true
177177
THIRD_PARTY_SIGNATURE_VERIFICATION_PUBLIC_KEYS: /app/keys/publickey.pem
178178
FORCE_VERIFYING_SIGNATURE: false
179+
180+
HTTP_PROXY: ${HTTP_PROXY:-http://ssrf_proxy:3128}
181+
HTTPS_PROXY: ${HTTPS_PROXY:-http://ssrf_proxy:3128}
182+
PLUGIN_PYTHON_ENV_INIT_TIMEOUT: ${PLUGIN_PYTHON_ENV_INIT_TIMEOUT:-120}
183+
extra_hosts:
184+
- "host.docker.internal:host-gateway"
179185
ports:
180186
- "${EXPOSE_PLUGIN_DAEMON_PORT:-5002}:${PLUGIN_DAEMON_PORT:-5002}"
181187
- "${EXPOSE_PLUGIN_DEBUGGING_PORT:-5003}:${PLUGIN_DEBUGGING_PORT:-5003}"

0 commit comments

Comments
 (0)