ai_old/js/lib/ai.ts
Star e69b9a3a12 add db、log support
support embedding for llm
support watch run for js
many other updates
2024-09-29 21:20:28 +08:00

87 lines
2.3 KiB
TypeScript

// just for develop
{{range .LLMList}}
let {{.}}: LLM
{{- end}}
export default {
similarity,
{{- range .LLMList}}
{{.}},
{{- end}}
}
function similarity(a: any, b: any): number{return 0}
interface ChatConfig {
model: string
ratio: number
maxTokens: number
temperature: number
topP: number
tools: Object
}
interface ChatResult {
result: string
askTokens: number
answerTokens: number
totalTokens: number
usedTime: number
}
interface GCConfig {
model: string
size: string
ref: string
}
interface GCResult {
result: string
preview: string
results: Array<string>
previews: Array<string>
usedTime: number
}
interface EmbeddingResult {
result: string
askTokens: number
answerTokens: number
totalTokens: number
usedTime: number
}
interface Support {
ask: boolean
askWithImage: boolean
askWithVideo: boolean
askWithCodeInterpreter: boolean
askWithWebSearch: boolean
makeImage: boolean
makeVideo: boolean
models: Array<string>
}
interface LLM {
ask(messages: any, config?: ChatConfig, callback?: (answer: string) => void): ChatResult
fastAsk(messages: any, callback?: (answer: string) => void): ChatResult
longAsk(messages: any, callback?: (answer: string) => void): ChatResult
batterAsk(messages: any, callback?: (answer: string) => void): ChatResult
bestAsk(messages: any, callback?: (answer: string) => void): ChatResult
multiAsk(messages: any, callback?: (answer: string) => void): ChatResult
bestMultiAsk(messages: any, callback?: (answer: string) => void): ChatResult
codeInterpreterAsk(messages: any, callback?: (answer: string) => void): ChatResult
webSearchAsk(messages: any, callback?: (answer: string) => void): ChatResult
makeImage(prompt: string, config?: GCConfig): GCResult
fastMakeImage(prompt: string, config?: GCConfig): GCResult
bestMakeImage(prompt: string, config?: GCConfig): GCResult
makeVideo(prompt: string, config?: GCConfig): GCResult
fastMakeVideo(prompt: string, config?: GCConfig): GCResult
bestMakeVideo(prompt: string, config?: GCConfig): GCResult
embedding(text: string, model: string): EmbeddingResult
fastEmbedding(text: string): EmbeddingResult
bestEmbedding(text: string): EmbeddingResult
support: Support
}