Skip to content

modules

Matt Busigin edited this page Nov 11, 2022 · 1 revision

@cognosis/platform / Exports

@cognosis/platform

Table of contents

Interfaces

Type Aliases

Variables

Functions

Type Aliases

llm_models

Ƭ llm_models: openai_models | nlpcloud_models

Defined in

workflows/llm.ts:14


nlpcloud_models

Ƭ nlpcloud_models: "gpt-neox-20b"

Defined in

workflows/llm.ts:13


openai_models

Ƭ openai_models: "gpt-3" | "text-curie-001"

Defined in

workflows/llm.ts:12

Variables

getOutputBuffer

Const getOutputBuffer: QueryDefinition<string, []>

Defined in

workflows/session.ts:5


userInputSignal

Const userInputSignal: SignalDefinition<[UserInput]>

Defined in

workflows/session.ts:14


userOutputListenerSignal

Const userOutputListenerSignal: SignalDefinition<[{ listener_wf: string ; target_wf: string }]>

Defined in

workflows/session.ts:16


userOutputSignal

Const userOutputSignal: SignalDefinition<[UserOutput]>

Defined in

workflows/session.ts:15

Functions

Chatbot

Chatbot(personality, context_length, user, message, session?, runCogs?): Promise<string>

Function

Invocation of chatbot function to generate a response to a message

Example

Example of a chatbot invocation

const response = await Chatbot( {name: "Gandalf", personaltity: "Wizard. Good, but unpredictable. Extremely powerful and wise."}, 50, 'user555555', 'Hello, there!' );

Parameters

Name Type Default value Description
personality Personality undefined -
context_length number undefined Number of previous messages to use as context
user string undefined User to respond to
message string undefined Message to respond to
session ChatSession undefined Chat session to use (default: new session)
runCogs boolean true Whether to run cogs (default: true)

Returns

Promise<string>

Defined in

workflows/chatbot.ts:72


ChatbotChuck

ChatbotChuck(user, message): Promise<string>

Invocation of Chatbot with the personality Chuck

Example

chatbot('anon55', 'Hello, how are you?')

Parameters

Name Type Description
user string The user
message string The message

Returns

Promise<string>

The response

Defined in

workflows/chatbot.ts:276


ChatbotNilp

ChatbotNilp(user, message): Promise<string>

Invocation of Chatbot with the personality Nilp

Example

chatbot('anon55', 'Hello, how are you?')

Parameters

Name Type Description
user string The user
message string The message

Returns

Promise<string>

The response

Defined in

workflows/chatbot.ts:290


DumpAndRestoreCogsetTeachings

DumpAndRestoreCogsetTeachings(): Promise<void>

Returns

Promise<void>

Defined in

workflows/chatbot.ts:416


IJavascript

IJavascript(query): Promise<string>

GPT-3 can use a IPython/Jupyter notebook "memetic proxy" to follow instructions while writing code to solve a problem. This is a workflow that uses the memetic proxy to solve a problem, as described passed as a string.

Example

const result = await executeJavascriptNotebook('The number of legs a spider has multiplied by the estimated population in France');

Parameters

Name Type Description
query string Instructions to follow which GPT-3 will try to use a Javascript Notebook to compose a solution

Returns

Promise<string>

Defined in

workflows/application/ijavascript.ts:15


IndexCog

IndexCog(cog): Promise<void>

Parameters

Name Type
cog Cog

Returns

Promise<void>

Defined in

workflows/chatbot.ts:394


NLPonDB

NLPonDB(query): Promise<any>

Parameters

Name Type
query string

Returns

Promise<any>

Defined in

workflows/mysql.ts:118


TranscriptToStructuredData

TranscriptToStructuredData(transcript): Promise<string>

Takes a transcription of a call and returns information about the call in JSON

Example

const callInfo = JSON.stringify( await getCallInfo('Caller: Hello, there!') );

Parameters

Name Type Description
transcript string Call transcription from call

Returns

Promise<string>

JSON string with information about the call

Defined in

workflows/application/call-transcription.ts:10


embeddings

embeddings(sentences): Promise<[string, number[]][]>

Parameters

Name Type
sentences string[]

Returns

Promise<[string, number[]][]>

Defined in

workflows/embeddings.ts:22


embeddingsFromTextSearch

embeddingsFromTextSearch(index, text, k): Promise<any[]>

Parameters

Name Type
index string
text string
k number

Returns

Promise<any[]>

Defined in

workflows/embeddings.ts:61


esMappings

esMappings(index, doc): Promise<void>

Parameters

Name Type
index string
doc any

Returns

Promise<void>

Defined in

workflows/elastic.ts:32


keywordsFromQuery

keywordsFromQuery(query): Promise<string>

Parameters

Name Type
query string

Returns

Promise<string>

Defined in

workflows/prompt.ts:197


logger

logger(msg): Promise<void>

Parameters

Name Type
msg string

Returns

Promise<void>

Defined in

workflows/util.ts:12


mapPromptTemplate

mapPromptTemplate(text, primarySummarizeTemplate?): Promise<string[]>

mapPromptTemplate

Parameters

Name Type Default value Description
text string undefined Input text to be processed
primarySummarizeTemplate string 'Analyze the following text for a detailed summary.\n\n{{{chunk}}}\n\nProvide a detailed summary:' Prompt template run on each chunk of text

Returns

Promise<string[]>

List of completions from running prompt primarySummarizeTemplate on each chunk of text

Defined in

workflows/prompt.ts:346


mapreduce_question_text

mapreduce_question_text(text, question, primarySummarizeTemplate?, reduceSummarizeTemplate?): Promise<string>

mapreduce_question_text

Parameters

Name Type Description
text string Text to be processed
question string -
primarySummarizeTemplate string -
reduceSummarizeTemplate string -

Returns

Promise<string>

A promise that resolves to the final answer

Defined in

workflows/prompt.ts:325


mapreduce_summary

mapreduce_summary(text, primarySummarizeTemplate?, reduceSummarizeTemplate?): Promise<string>

Parameters

Name Type Default value Description
text string undefined Text to summarize which is potentially larger than the context-size of the LLM model
primarySummarizeTemplate string 'Analyze the following text for a detailed summary.\n\n{{{chunk}}}\n\nProvide a detailed summary:' Template to use for the map step summary
reduceSummarizeTemplate string 'These are a series of summaries that you are going to summarize:\n\n{{{chunk}}}\n\nProvide a detailed summary in the 3rd party passive voice, removing duplicate information:' Teomplate to use for the reduce step summary

Returns

Promise<string>

A summary of the text

Defined in

workflows/prompt.ts:307


minGenerate

minGenerate(prompt, minLength, maxLength, temperature, endSequence?, model?): Promise<string>

Function

minGenerate

Description

A workflow that will generate text using sensible defaults to a sensible default LLM

Parameters

Name Type Default value
prompt string undefined
minLength number undefined
maxLength number undefined
temperature number undefined
endSequence null | string null
model llm_models 'gpt-3'

Returns

Promise<string>

Defined in

workflows/llm.ts:119


mysqlQuery

mysqlQuery<T>(dbhost, dbuser, dbpassword, dbname, sql, parameters): Promise<T[]>

Function

mysqlQuery

Description

A workflow that simply calls an activity

Type parameters

Name
T

Parameters

Name Type
dbhost string
dbuser string
dbpassword string
dbname string
sql string
parameters any[]

Returns

Promise<T[]>

Defined in

workflows/mysql.ts:27


nlpcloud_generate

nlpcloud_generate(prompt, minLength?, maxLength?, lengthNoInput?, endSequence?, removeInput?, doSample, numBeams, earlyStopping, noRepeatNgramSize, numReturnSequences, topK, topP, temperature, repetitionPenalty, lengthPenalty, badWords, removeEndSequence): Promise<string>

Function

nlpcloud_generate

Description

A workflow that will generate text using the NLP Cloud API

Parameters

Name Type Default value
prompt string undefined
minLength number 10
maxLength number 20
lengthNoInput null | boolean null
endSequence null | string null
removeInput boolean true
doSample null | boolean undefined
numBeams null | number undefined
earlyStopping null | boolean undefined
noRepeatNgramSize null | number undefined
numReturnSequences null | number undefined
topK null | number undefined
topP null | number undefined
temperature null | number undefined
repetitionPenalty null | number undefined
lengthPenalty null | number undefined
badWords null | boolean undefined
removeEndSequence null | boolean undefined

Returns

Promise<string>

Defined in

workflows/llm.ts:38


openai_generate

openai_generate(prompt, min_length, max_length, temperature, top_p): Promise<string>

Function

openai_generate

Description

A workflow that will generate text using the OpenAI API

Parameters

Name Type
prompt string
min_length number
max_length number
temperature number
top_p number

Returns

Promise<string>

Defined in

workflows/llm.ts:93


post_message_filtering

post_message_filtering(session): Promise<string>

Parameters

Name Type
session ChatSession

Returns

Promise<string>

Defined in

workflows/chatbot.ts:421


promptReducer

promptReducer(inPrompt, variables, preamble, instructions): Promise<string>

Parameters

Name Type
inPrompt string
variables any
preamble string
instructions string

Returns

Promise<string>

Defined in

workflows/prompt.ts:160


promptTemplate

promptTemplate<T>(template, variables, minLength?, maxLength?, temperature?, model?): Promise<string>

Type parameters

Name
T

Parameters

Name Type Default value
template string undefined
variables T undefined
minLength number 1
maxLength number 50
temperature number 0.0
model "gpt-3" | "gpt-neox-20b" 'gpt-neox-20b'

Returns

Promise<string>

Defined in

workflows/prompt.ts:15


questionAndAnswer

questionAndAnswer(index, query): Promise<QandA>

Parameters

Name Type
index string
query string

Returns

Promise<QandA>

Defined in

workflows/prompt.ts:216


read

read(wfid): Promise<string>

Parameters

Name Type
wfid string

Returns

Promise<string>

Defined in

workflows/session.ts:181


reducePromptTemplate

reducePromptTemplate(completions, reduceTemplate?): Promise<string>

reducePromptTemplate

Parameters

Name Type Default value Description
completions string[] undefined Array of completions, usually output from mapPromptTemplate
reduceTemplate string 'These are a series of summaries that you are going to summarize:\n\n{{{chunk}}}\n\nProvide a detailed summary, but removing duplicate information:' Prompt template run on completions to reduce them to a single summary

Returns

Promise<string>

Final return value of the reduce prompt templates being run on completions from the map prompt templates.

Defined in

workflows/prompt.ts:371


send

send(wfid, message): Promise<void>

Parameters

Name Type
wfid string
message FrameInput

Returns

Promise<void>

Defined in

workflows/session.ts:175


sendread

sendread(wfid, message): Promise<string>

Parameters

Name Type
wfid string
message Frame

Returns

Promise<string>

Defined in

workflows/session.ts:198


splitPromptTemplateByLinesOfTokens

splitPromptTemplateByLinesOfTokens(data, template, minLength?, maxLength?, temperature?): Promise<[string, string, number[]][]>

Parameters

Name Type Default value
data string undefined
template string undefined
minLength number 1
maxLength number 50
temperature number 0.0

Returns

Promise<[string, string, number[]][]>

Defined in

workflows/prompt.ts:83


splitPromptTemplateByTokens

splitPromptTemplateByTokens(data, template, minLength?, maxLength?, temperature?): Promise<[string, string][]>

Function

splitPromptTemplateByTokens

Parameters

Name Type Default value
data string undefined
template string undefined
minLength number 1
maxLength number 50
temperature number 0.0

Returns

Promise<[string, string][]>

Defined in

workflows/prompt.ts:47


stable_diffusion

stable_diffusion(prompt): Promise<string>

Parameters

Name Type
prompt string

Returns

Promise<string>

Defined in

workflows/util.ts:8


storeEmbeddings

storeEmbeddings(sentences, index, documents, alsoTokenize?): Promise<string>

Parameters

Name Type Default value
sentences string[] undefined
index string undefined
documents any[] undefined
alsoTokenize boolean false

Returns

Promise<string>

Defined in

workflows/embeddings.ts:28


testSession

testSession(first_message): Promise<void>

Parameters

Name Type
first_message Frame

Returns

Promise<void>

Defined in

workflows/session.ts:217


translateQuerySpaceToAnswerSpace

translateQuerySpaceToAnswerSpace(query): Promise<string>

Parameters

Name Type
query string

Returns

Promise<string>

Defined in

workflows/prompt.ts:179


wf_esindex

wf_esindex(pindex, pdocument): Promise<void>

Function

wf_esindex

Description

A workflow that will index a document into Elasticsearch

Parameters

Name Type
pindex string
pdocument any

Returns

Promise<void>

Defined in

workflows/elastic.ts:14


wf_essearch

wf_essearch(index, query): Promise<any>

Function

wf_essearch

Description

A workflow that will search Elasticsearch

Parameters

Name Type
index string
query any

Returns

Promise<any>

Defined in

workflows/elastic.ts:27


xNLPonDB

xNLPonDB(host, username, password, dbname, query): Promise<any>

Function

xNLPonDB

Description

Takes a natural language query and translates it into SQL.

Parameters

Name Type Description
host string -
username string -
password string -
dbname string -
query string The natural language query to parse.

Returns

Promise<any>

  • The results of the SQL query.

Defined in

workflows/mysql.ts:44

Clone this wiki locally