PaddlePaddle / ERNIE-SDK

ERNIE Bot Agent is a Large Language Model (LLM) Agent Framework, powered by the advanced capabilities of ERNIE Bot and the platform resources of Baidu AI Studio.
http://ernie-bot-agent.readthedocs.io/
Apache License 2.0
343 stars 52 forks source link

可以在XAgent中调用ernie-bot-4吗? #87

Closed CQxiaocaimi closed 7 months ago

CQxiaocaimi commented 10 months ago

如题,我知道是可以的,但是遇到一些问题,报错:KeyError: 'Could not automatically map ernie-bot-4 to a tokeniser. Please use tiktoken.get_encoding to explicitly get the tokeniser you expect. 需要提供模型的分词器给XAgent以支持Context管理功能,但是我不知道该怎么做,不太懂代码。 XAgent中的utils.py代码部分有: from enum import Enum, unique import abc from colorama import Fore, Style import json import requests from dataclasses import dataclass, field from typing import List, Dict import tiktoken from XAgent.config import CONFIG

encoding = tiktoken.encoding_for_model(CONFIG.default_completion_kwargs['model'])

def get_token_nums(text:str)->int: return len(encoding.encode(text))

def clip_text(text:str,max_tokens:int=None,clip_end=False)->str|int: encoded = encoding.encode(text) decoded = encoding.decode(encoded[:max_tokens] if clip_end else encoded[-max_tokens:]) if len(decoded) != len(text): decoded = decoded + 'wrapped' if clip_end else 'wrapped' + decoded return decoded, len(encoded)

@unique class LLMStatusCode(Enum): SUCCESS = 0 ERROR = 1

@unique class ToolCallStatusCode(Enum): TOOL_CALL_FAILED = -1 TOOL_CALL_SUCCESS = 0 FORMAT_ERROR = 1 HALLUCINATE_NAME = 2 OTHER_ERROR = 3 TIMEOUT_ERROR = 4 TIME_LIMIT_EXCEEDED = 5 SERVER_ERROR = 6 是需要克隆ernie-bot-sdk?还是需要下载paddlepaddle,还是paddleNLP。我以为仅仅需要API就可以的。。。。

sijunhe commented 10 months ago

您好,ernie-bot和ernie-bot-4的tokenizer并没有公开哟,只公开了模型API