lobehub / lobe-chat-agents

🤖 / 🏪 Agent Index - This is the agent index for LobeChat. It accesses index.json from this repository to display a list of available agents for LobeChat to the agent market.
https://chat-agents.lobehub.com
437 stars 157 forks source link

Remove the usage of ChatOpenAI from the langchain package and switch to using OpenAI for i18n translation. #881

Closed a327958099 closed 2 weeks ago

a327958099 commented 2 weeks ago

When using i18n for multilingual translation, we utilized the ChatOpenAI method from the langchain package for large model translation. However, we are currently encountering some errors. I believe these issues are caused by an outdated version of the langchain package. Since we are only calling the OpenAI API, we should not rely on this relatively large langchain package. Directly using the OpenAI package for processing can effectively avoid compatibility issues between different versions.
Resolved error issues:
ℹ i18n generating... 12:29:11 PM 1 | (function (process,nextTickQueue,drainMicrotasksFn,reportUncaughtExceptionFn){"use strict";var queue,process,nextTickQueue=nextTickQueue,drainMicrotasks=drainMicrotasksFn,reportUncaughtException=reportUncaughtExceptionFn;function validateFunction(cb){if(typeof cb!=="function"){const err=@makeTypeError(The "callback" argument must be of type "function". Received type ${typeof cb});throw err.code="ERR_INVALID_ARG_TYPE",err}}var setup=()=>{queue=function createQueue(){class FixedCircularBuffer{constructor(){this.bottom=0,this.top=0,this.list=@newArrayWithSize(2048),this.next=null}isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&2047)===this.bottom}push(data){this.list[this.top]=data,this.top=this.top+1&2047}shift(){var{list,bottom}=this;const nextItem=list[bottom];if(nextItem===@undefined)return null;return list[bottom]=@undefined,this.bottom=bottom+1&2047,nextItem}}class FixedQueue{constructor(){this.head=this.tail=new FixedCircularBuffer}isEmpty(){return this.head.isEmpty()}push(data){if(this.head.isFull())this.head=this.head.next=new FixedCircularBuffer;this.head.push(data)}shift(){const tail=this.tail,next=tail.shift();if(tail.isEmpty()&&tail.next!==null)this.tail=tail.next,tail.next=null;return next}}return new FixedQueue}();function processTicksAndRejections(){var tock;do{while((tock=queue.shift())!==null){var{callback,args,frame}=tock,restore=@getInternalField(@asyncContext,0);@putInternalField(@asyncContext,0,frame);try{if(args===@undefined)callback();else switch(args.length){case 1:callback(args[0]);break;case 2:callback(args[0],args[1]);break;case 3:callback(args[0],args[1],args[2]);break;case 4:callback(args[0],args[1],args[2],args[3]);break;default:callback(...args);break}}catch(e){reportUncaughtException(e)}finally{@putInternalField(@asyncContext,0,restore)}}drainMicrotasks()}while(!queue.isEmpty())}@putInternalField(nextTickQueue,0,0),@putInternalField(nextTickQueue,1,queue),@putInternalField(nextTickQueue,2,processTicksAndRejections),setup=@undefined};function nextTick(cb,args){if(validateFunction(cb),setup)setup(),process=globalThis.process;if(process._exiting)return;queue.push({callback:cb,args:@argumentCount()>1?@Array.prototype.slice.@call(arguments,1):@undefined,frame:@getInternalField(@asyncContext,0)}),@putInternalField(nextTickQueue,0,1)}return nextTick}) ^ SyntaxError: JSON Parse error: Expected ':' before value in object property definition at processTicksAndRejections (:1:2602)

lobehubbot commented 2 weeks ago

👍 @a327958099

Thank you for raising your pull request and contributing to our Community Please make sure you have followed our contributing guidelines. We will review it as soon as possible. If you encounter any problems, please feel free to connect with us.\ 非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。 如果您遇到任何问题,请随时与我们联系。

a327958099 commented 2 weeks ago

Sorry, the bug doesn't seem to be caused by this issue.