Replies: 1 comment 3 replies
-
@2500035435 Hello! I'm here to help you with your GitHub issues. I can help you solve bugs, answer questions, and become a contributor. The issue you're encountering with the In your case, the 'query' parameter contains Unicode characters that are not properly handled, causing the To resolve this, ensure that the 'query' parameter is properly sanitized and encoded to handle Unicode characters. Here is a relevant part of the code that validates the input variables: class RetrieverInput(BaseModel):
"""Input to the retriever."""
query: str = Field(description="query to look up in retriever") If the 'query' parameter contains Unicode characters, it must be properly handled to prevent validation errors. You can sanitize and encode the 'query' parameter before passing it to the tool. Additionally, ensure that the @root_validator(pre=False, skip_on_failure=True)
def validate_api_request_prompt(cls, values: Dict) -> Dict:
input_vars = values["api_request_chain"].prompt.input_variables
expected_vars = {"question", "api_docs"}
if set(input_vars) != expected_vars:
raise ValueError(f"Input variables should be {expected_vars}, got {input_vars}")
return values
@root_validator(pre=False, skip_on_failure=True)
def validate_api_answer_prompt(cls, values: Dict) -> Dict:
input_vars = values["api_answer_chain"].prompt.input_variables
expected_vars = {"question", "api_docs", "api_url", "api_response"}
if set(input_vars) != expected_vars:
raise ValueError(f"Input variables should be {expected_vars}, got {input_vars}")
return values Ensure that the 'query' parameter is properly formatted and encoded to handle Unicode characters to prevent these validation errors [1][2]. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I use milvus database as vector store to build RAG, follow the langchain tutorials to create tool, but when I use tool and it return some error.
I notice that in the first llm the glm4 does give the argument:
function=FunctionCall(name='荔枝知识增强检索', arguments='{"function_name": "荔枝知识增强检索", "parameters": {"query": "请问有哪些荔枝品种?"}}'), type='function')
I think it seems right, this is the right argument format? After the agent, langchain gave some wrong input in the second llm, that cause the (Error: ValidationError)
Why the second call request have Unicode character:
arguments='{"function_name": "\\u8354\\u679d\\u77e5\\u8bc6\\u589e\\u5f3a\\u68c0\\u7d22", "parameters": {"query": "\\u8bf7\\u95ee\\u6709\\u54ea\\u4e9b\\u8354\\u679d\\u54c1\\u79cd\\uff1f"}}'), type='function')])
and tool message with error.
ChatMessage(role='tool', content="Error: ValidationError(model='RetrieverInput', errors=[{'loc': ('query',), 'msg': 'field required', 'type': 'value_error.missing'}])\n Please fix your mistakes."
What am I supposed to do to fix this problem and use tool successfully?
Thank you very much for your suggestions and solutions
System Info
python--3.11.9
langchain--0.2.11
langgraph--0.2.14
langchain-openai--0.1.22
Beta Was this translation helpful? Give feedback.
All reactions