default_chunk_class = AIMessageChunk
for chunk in res.iter_lines():
response = json.loads(chunk)
if "error" in response:
raise ValueError(f"Error from Hunyuan api response: {response}")
for choice in response["choices"]:
chunk = _convert_delta_to_message_chunk(
choice["delta"], default_chunk_class
)
default_chunk_class = chunk.__class__
cg_chunk = ChatGenerationChunk(message=chunk)
if run_manager:
run_manager.on_llm_new_token(chunk.content, chunk=cg_chunk)
yield cg_chunk
![Uploading langchainb
ug1.png…]()
Description
langchain_community.chat_models ChatHunyuan had a bug JSON parsing error
it is not a json!
Checked other resources
Example Code
import langchain from langchain_community.chat_models import ChatHunyuan from langchain_core.messages import HumanMessage
print(langchain.version) hunyuan_app_id = "**" hunyuan_secret_id = "****" hunyuan_secret_key = "***" llm_tongyi = ChatHunyuan(streaming=True, hunyuan_app_id=hunyuan_app_id, hunyuan_secret_id=hunyuan_secret_id, hunyuan_secret_key=hunyuan_secret_key) print(llm_tongyi.invoke("how old are you"))
Error Message and Stack Trace (if applicable)
def _stream( self, messages: List[BaseMessage], stop: Optional[List[str]] = None, run_manager: Optional[CallbackManagerForLLMRun] = None, kwargs: Any, ) -> Iterator[ChatGenerationChunk]: res = self._chat(messages, kwargs)
![Uploading langchainb ug1.png…]()
Description
langchain_community.chat_models ChatHunyuan had a bug JSON parsing error it is not a json!
System Info
langchain version 0.1.9 windows 3.9.13