Closed ansarizafar closed 1 year ago
I have converted response from markdown to text but still Langchain is not executing Great tool _call method. Here is the model code
import Bard from "bard-ai";
import removeMarkdown from "markdown-to-text";
import { LLM } from "langchain/llms/base"
export class BardAI extends LLM {
constructor(config) {
super(config);
this.model = Bard
this.controller = new AbortController();
this.markdown = config.markdown || false
}
async init(token) {
await Bard.init(token)
}
async _call(prompt, options = { signal: controller.signal }, runManager) {
//return this.caller.call(this.model.askAI.bind(this.model), prompt)
// const result = await this.caller.call(this.model.askAI.bind(this.model), prompt)
let result = await this.model.askAI(prompt)
if (!this.markdown) {
result = removeMarkdown.default(result)
// console.log(result)
return result
}
return result
}
_llmType() {
return 'bard.chat'
}
cancel() {
this.controller.abort();
}
}
Unfortunately I am not familiar with langchainjs
. If you believe that this is a specific issue with bard-ai
, please elaborate, and I will be glad to help. Otherwise, if it is an issue with integration and/or langchainjs
itself, then I am not able to help, as I am not familiar. Try posting it in another place. Thank you!
I am trying to use bard-ai with langchainjs https://js.langchain.com/docs/ Here is the code of my custom langchain model with bard-ai
The model is working fine with lanchainjs except with initializeAgentExecutorWithOptions. Following code is not working.
Here is the output
I think the reason is that the bard-ai is returning response as markdown where as langchainjs is expecting text. Langchainjs integration will make bard-ai more useful If we can fix this issue.