[GH-ISSUE #1025] Does the api not support Chinese prompt? #632

Closed
opened 2026-02-22 18:20:34 -05:00 by yindo · 1 comment
Owner

Originally created by @17Reset on GitHub (Apr 3, 2024).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/1025

When I call AnythingLLM's API in Python, and I ask a question in Chinese, the return is garbled:

def anythingllm_chat(ipv4, port, api_key, slug, prompt):
    url = f'http://{ipv4}:{port}/api/v1/workspace/{slug}/stream-chat'
    headers = {
        'accept': 'application/json',
        'Authorization': f'Bearer {api_key}',
        'Content-Type': 'application/json; charset=utf-8'
    }
    data = {
        'message': prompt,
        'model': 'chat',
    }
    try:
        response = requests.post(url, headers=headers, json=data, stream=True)
    except Exception as exception:
		print(exception)
        return
    for line in response.iter_content(None, decode_unicode=True):
        try:
            data = json.loads(line[5:])
            if 'textResponse' in data:
                print(data['textResponse'], end='', flush=True)
        except Exception as exception:
            continue

if __name__ == '__main__':
    PROMPT = 'Vitis HLS 的竞争对手有哪些?'
    anythingllm_chat(
        ipv4=IPV4,
        port=PORT,
        api_key=API_KEY,
        slug=slug,
        prompt=PROMPT,
    )

Vitis High-Level Synthesis (HLS) 是 Xilinx 公司推出的一种高层次综合(HLS)工具,它可以将 C 和 C++ 代码转换为可编程逻辑电路。以下是一些与 Vitis HLS 类似的竞争对手:

1. Synopsys Design Compiler (DC):Synopsys 的 DC 是一个广泛使用的综合工具,它可以支持多种不同的设计输入格式,包括 Verilog、VHDL 和 SystemC 等。它还可以进行高层次综合和布局布线等操作。
2. Cadence ConnXt: Cadence 的 ConnXt 也是一个高层次综合工具,它可以将 C 和 C++ 代码转换为可编程逻辑电路。它还支持多种不同的设计输入格式,包括 Verilog、VHDL 和 SystemC 等。
3. Mentor Graphics Veloce: Mentor Graphics 的 Veloce 是一个仿真和验证工具,它可以对高层次综合后的设计进行仿真和验证。它还可以支持多种不同的设计输入格式,包括 Verilog、VHDL 和 SystemC 等。
4. Synopsys HAPS: Synopsys 的 HAPS 是一个硬件加速器,它可以对高层次综合后的设计进行仿真和验证。它还支持多种不同的设计输入格式,包括 Verilog、VHDL 和 SystemC 等。
5. Cadence Protium S1: Cadence 的 Protium S1 也是一个硬件加速器,它可以对高层次综合后的设计进行仿真和验证。它还可以支持多种不同的设计输入格式,包括 Verilog、VHDL 和 SystemC 等ã
Originally created by @17Reset on GitHub (Apr 3, 2024). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/1025 When I call AnythingLLM's API in Python, and I ask a question in Chinese, the return is garbled: ```python def anythingllm_chat(ipv4, port, api_key, slug, prompt): url = f'http://{ipv4}:{port}/api/v1/workspace/{slug}/stream-chat' headers = { 'accept': 'application/json', 'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json; charset=utf-8' } data = { 'message': prompt, 'model': 'chat', } try: response = requests.post(url, headers=headers, json=data, stream=True) except Exception as exception: print(exception) return for line in response.iter_content(None, decode_unicode=True): try: data = json.loads(line[5:]) if 'textResponse' in data: print(data['textResponse'], end='', flush=True) except Exception as exception: continue if __name__ == '__main__': PROMPT = 'Vitis HLS 的竞争对手有哪些?' anythingllm_chat( ipv4=IPV4, port=PORT, api_key=API_KEY, slug=slug, prompt=PROMPT, ) ``` Vitis High-Level Synthesis (HLS) 是 Xilinx 公司推出的一种高层次综合(HLS)工具,它可以将 C 和 C++ 代码转换为可编程逻辑电路。以下是一些与 Vitis HLS 类似的竞争对手: ``` 1. Synopsys Design Compiler (DC):Synopsys 的 DC 是一个广泛使用的综合工具,它可以支持多种不同的设计输入格式,包括 Verilog、VHDL 和 SystemC 等。它还可以进行高层次综合和布局布线等操作。 2. Cadence ConnXt: Cadence 的 ConnXt 也是一个高层次综合工具,它可以将 C 和 C++ 代码转换为可编程逻辑电路。它还支持多种不同的设计输入格式,包括 Verilog、VHDL 和 SystemC 等。 3. Mentor Graphics Veloce: Mentor Graphics 的 Veloce 是一个仿真和验证工具,它可以对高层次综合后的设计进行仿真和验证。它还可以支持多种不同的设计输入格式,包括 Verilog、VHDL 和 SystemC 等。 4. Synopsys HAPS: Synopsys 的 HAPS 是一个硬件加速器,它可以对高层次综合后的设计进行仿真和验证。它还支持多种不同的设计输入格式,包括 Verilog、VHDL 和 SystemC 等。 5. Cadence Protium S1: Cadence 的 Protium S1 也是一个硬件加速器,它可以对高层次综合后的设计进行仿真和验证。它还可以支持多种不同的设计输入格式,包括 Verilog、VHDL 和 SystemC 等ã ```
yindo closed this issue 2026-02-22 18:20:34 -05:00
Author
Owner

@timothycarambat commented on GitHub (Apr 3, 2024):

Looks like the response charset is not set in response and so the assumed charset cannot parse those values, even though you set it in the request
https://github.com/expressjs/express/wiki/Migrating%20from%203.x%20to%204.x#rescharset

@timothycarambat commented on GitHub (Apr 3, 2024): Looks like the response charset is not set in response and so the assumed charset cannot parse those values, even though you set it in the request https://github.com/expressjs/express/wiki/Migrating%20from%203.x%20to%204.x#rescharset
yindo changed title from Does the api not support Chinese prompt? to [GH-ISSUE #1025] Does the api not support Chinese prompt? 2026-06-05 14:36:23 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#632