Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
samhithanair authored Oct 13, 2023
1 parent dddcddc commit 6564431
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { RetrievalQAChain } from 'langchain/chains'
import { BaseRetriever } from 'langchain/schema/retriever'

Check warning on line 3 in packages/components/nodes/chains/ImageConversationChain/ImageConversationChain.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

'BaseRetriever' is defined but never used
import { getBaseClasses } from '../../../src/utils'
import { BaseLanguageModel } from 'langchain/base_language'

Check warning on line 5 in packages/components/nodes/chains/ImageConversationChain/ImageConversationChain.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

'BaseLanguageModel' is defined but never used
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'

class ImageConversationChain_Chains implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
baseClasses: string[]
description: string
inputs: INodeParams[]

constructor() {
this.label = 'Image Conversation Chain'
this.name = 'imageConversationChain'
this.version = 1.0
this.type = 'ImageConversationChain'
this.icon = 'image.png'
this.category = 'Chains'
this.description = 'QA chain to answer a question based on the retrieved images'
this.baseClasses = [this.type, ...getBaseClasses(RetrievalQAChain)]
this.inputs = [
{
label: 'Image',
name: 'Image',
type: 'Image'
},
{
label: 'myBard',
name: 'myBard',
type: 'myBard'
}
]
}

async init(nodeData: INodeData): Promise<any> {
const myBard = nodeData.inputs?.myBard

Check warning on line 43 in packages/components/nodes/chains/ImageConversationChain/ImageConversationChain.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

'myBard' is assigned a value but never used. Allowed unused vars must match /^_/u
const image = nodeData.inputs?.image as string

Check warning on line 44 in packages/components/nodes/chains/ImageConversationChain/ImageConversationChain.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

'image' is assigned a value but never used. Allowed unused vars must match /^_/u

//const chain = RetrievalQAChain.fromLLM(model, vectorStoreRetriever, { verbose: process.env.DEBUG === 'true' ? true : false })
//return chain
}

async run(nodeData: INodeData, input: string, options: ICommonObject): Promise<string> {
const chain = nodeData.instance as RetrievalQAChain
const myBard = nodeData.inputs?.myBard
const image = nodeData.inputs?.image as string
const obj = {
query: input
}
const loggerHandler = new ConsoleCallbackHandler(options.logger)
const callbacks = await additionalCallbacks(nodeData, options)

if (options.socketIO && options.socketIOClientId) {
const handler = new CustomChainHandler(options.socketIO, options.socketIOClientId)
const res = await chain.call(obj, [loggerHandler, handler, ...callbacks])

Check warning on line 62 in packages/components/nodes/chains/ImageConversationChain/ImageConversationChain.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

'res' is assigned a value but never used. Allowed unused vars must match /^_/u
return (await myBard.ask(obj, {image: image}))

Check failure on line 63 in packages/components/nodes/chains/ImageConversationChain/ImageConversationChain.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Replace `(await·myBard.ask(obj,·{image:·image})` with `await·myBard.ask(obj,·{·image:·image·}`
} else {
const res = await chain.call(obj, [loggerHandler, ...callbacks])

Check warning on line 65 in packages/components/nodes/chains/ImageConversationChain/ImageConversationChain.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

'res' is assigned a value but never used. Allowed unused vars must match /^_/u
return (await myBard.ask(obj, {image: image}))

Check failure on line 66 in packages/components/nodes/chains/ImageConversationChain/ImageConversationChain.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Replace `(await·myBard.ask(obj,·{image:·image})` with `await·myBard.ask(obj,·{·image:·image·}`
}
}
}

module.exports = { nodeClass: ImageConversationChain_Chains }
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6564431

Please sign in to comment.