repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
genaiscript
github_2023
microsoft
typescript
TestHost.removeBrowsers
async removeBrowsers(): Promise<void> {}
// Async method to remove browsers
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/testhost.ts#L222-L222
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
TestHost.select
select(message: string, options: string[]): Promise<string> { throw new Error("Method not implemented.") }
// Placeholder for selecting an option from a list
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/testhost.ts#L225-L227
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
TestHost.input
input(message: string): Promise<string> { throw new Error("Method not implemented.") }
// Placeholder for input functionality
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/testhost.ts#L230-L232
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
TestHost.confirm
confirm(message: string): Promise<boolean> { throw new Error("Method not implemented.") }
// Placeholder for confirmation functionality
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/testhost.ts#L235-L237
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
MarkdownTrace.table
table( rows: object[], options?: { headers?: ElementOrArray<string> } ): void { if (!rows?.length) return const md = dataToMarkdownTable(rows, options) this.appendContent(`\n\n${md}\n\n`) }
/** * Logs a markdown table * @param rows */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/trace.ts#L126-L133
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
GenerationStats.constructor
constructor(model: string, label?: string) { this.model = model this.label = label this.usage = { completion_tokens: 0, prompt_tokens: 0, total_tokens: 0, completion_tokens_details: { audio_tokens: 0, reasoning_token...
/** * Constructs a GenerationStats instance. * * @param model - The model used for chat completions. * @param label - Optional label for the statistics. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/usage.ts#L94-L112
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
GenerationStats.cost
cost(): number { return [ ...this.chatTurns.map( ({ usage, model }) => estimateCost(model, usage) ?? estimateCost(this.model, usage) ), ...this.children.map((c) => c.cost()), ].reduce((a, b) => (a ?? 0) + (b ?? 0...
/** * Calculates the total cost based on the usage statistics. * * @returns The total cost. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/usage.ts#L123-L132
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
GenerationStats.accumulatedUsage
accumulatedUsage(): ChatCompletionUsage { const res: ChatCompletionUsage = structuredClone(this.usage) for (const child of this.children) { const childUsage = child.accumulatedUsage() res.completion_tokens += childUsage.completion_tokens res.prompt_tokens += childUsag...
/** * Accumulates the usage statistics from this instance and its children. * * @returns The accumulated usage statistics. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/usage.ts#L139-L162
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
GenerationStats.createChild
createChild(model: string, label?: string) { const child = new GenerationStats(model, label) this.children.push(child) return child }
/** * Creates a new child GenerationStats instance. * * @param model - The model used for the child chat completions. * @param label - Optional label for the child's statistics. * @returns The created child GenerationStats instance. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/usage.ts#L171-L175
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
GenerationStats.trace
trace(trace: MarkdownTrace) { trace.startDetails("🪙 generation stats") try { this.traceStats(trace) } finally { trace.endDetails() } }
/** * Traces the generation statistics using a MarkdownTrace instance. * * @param trace - The MarkdownTrace instance used for tracing. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/usage.ts#L182-L189
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
GenerationStats.traceStats
private traceStats(trace: MarkdownTrace) { trace.itemValue("prompt", this.usage.prompt_tokens) trace.itemValue("completion", this.usage.completion_tokens) trace.itemValue("tokens", this.usage.total_tokens) const c = renderCost(this.cost()) if (c) trace.itemValue("cost", c) ...
/** * Helper method to trace individual statistics. * * @param trace - The MarkdownTrace instance used for tracing. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/usage.ts#L196-L248
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
GenerationStats.log
log() { this.logTokens("") }
/** * Logs the generation statistics. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/usage.ts#L253-L255
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
GenerationStats.logTokens
private logTokens(indent: string) { const unknowns = new Set<string>() const c = this.cost() const au = this.accumulatedUsage() if (au?.total_tokens > 0 && (this.resolvedModel || c)) { logVerbose( `${indent}${this.label ? `${this.label} (${this.resolvedModel})...
/** * Helper method to log tokens with indentation. * * @param indent - The indentation used for logging. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/usage.ts#L262-L297
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
GenerationStats.addUsage
addUsage(req: CreateChatCompletionRequest, resp: ChatCompletionResponse) { const { usage = { completion_tokens: 0, prompt_tokens: 0, total_tokens: 0 }, model, cached, } = resp const { messages } = req if (!cached) { this.usage.completion_t...
/** * Adds usage statistics to the current instance. * * @param req - The request containing details about the chat completion. * @param usage - The usage statistics to be added. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/usage.ts#L305-L340
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
OpenAIEmbeddings.constructor
public constructor( readonly info: ModelConnectionOptions, readonly configuration: LanguageModelConfiguration, readonly options?: TraceOptions ) { this.cache = JSONLineCache.byName< EmbeddingsCacheKey, EmbeddingsResponse >("embeddings") }
/** * Constructs an instance of OpenAIEmbeddings. * @param info Connection options for the model. * @param configuration Configuration for the language model. * @param options Options for tracing. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/vectorsearch.ts#L59-L68
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
OpenAIEmbeddings.createEmbeddings
public async createEmbeddings( inputs: string | string[] ): Promise<EmbeddingsResponse> { const { provider, base, model } = this.configuration // Define the cache key for the current request const cacheKey: EmbeddingsCacheKey = { inputs, model, provider, base } // Check if ...
/** * Creates embeddings for the given inputs using the OpenAI API. * @param inputs Text inputs to create embeddings for. * @returns A `EmbeddingsResponse` with a status and the generated embeddings or a message when an error occurs. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/vectorsearch.ts#L78-L95
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
OpenAIEmbeddings.uncachedCreateEmbeddings
private async uncachedCreateEmbeddings( input: string | string[] ): Promise<EmbeddingsResponse> { const { provider, base, model, type } = this.configuration const { trace } = this.options || {} const body: EmbeddingCreateParams = { input, model } let url: string const...
/** * Creates embeddings without using the cache. * @param input The input text or texts. * @returns The response containing the embeddings or error information. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/vectorsearch.ts#L102-L161
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
toURLSearchParams
function toURLSearchParams(o: any) { const params = new URLSearchParams() for (const key in o) { if (o.hasOwnProperty(key) && o[key] !== undefined) { params.append(key, o[key]) } } return params.toString() }
/** * Converts an object into a URL search parameters string. * Iterates over object properties and appends them to a URLSearchParams instance. * @param o - The object to be converted. * @returns A string representing URL search parameters. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/core/src/websearch.ts#L19-L27
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
foo
function foo() { // hello //# blah }
//# A command line app that makes pictures black & white
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/sample/src/sample.ts#L2-L5
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
generateCreditCardNumber
function generateCreditCardNumber(): string { // Define the prefix for Visa cards const prefix = "400000" // Define the total length of the credit card number const length = 16 // Initialize the card number with the prefix let cardNumber = prefix // Loop until the card number reaches the de...
// Function to generate a credit card number
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/sample/src/edits/bigfibs/fib.ts#L2-L20
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
getCheckDigit
function getCheckDigit(cardNumber: string): string { // Initialize the sum to 0 let sum = 0 // Flag to determine whether to double the digit or not let shouldDouble = true // Loop through the card number digits from right to left for (let i = cardNumber.length - 1; i >= 0; i--) { // Par...
// Function to calculate the check digit using the Luhn algorithm
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/sample/src/edits/bigfibs/fib.ts#L23-L53
fde9f9a763333bd67ede17209c4b32ba17df94f2
genaiscript
github_2023
microsoft
typescript
parseCodeBlockStart
function parseCodeBlockStart(line: string): ICodeBlockStart | null { const match = line.match(/^```(\S*)\s*(.+)?$/) return ( match && { langId: match[1], options: match[2] || "", } ) }
/** * Note - the indented code block parsing is basic. It should only be applied inside lists, * indentation should be consistent across lines and * between the start and end blocks, etc. This is good enough for typical use cases. */
https://github.com/microsoft/genaiscript/blob/fde9f9a763333bd67ede17209c4b32ba17df94f2/packages/vscode/src/docsnotebook.ts#L361-L369
fde9f9a763333bd67ede17209c4b32ba17df94f2
whisper-turbo
github_2023
FL33TW00D
typescript
InferenceSession.constructor
constructor(session: Comlink.Remote<Session> | Session, worker?: Worker) { this.session = session; this.innerWorker = worker || null; }
//Keep a reference to the worker so we can terminate it
https://github.com/FL33TW00D/whisper-turbo/blob/54916ad654a24b6424ca2052651dc384de7d66ed/src/inferenceSession.ts#L12-L15
54916ad654a24b6424ca2052651dc384de7d66ed
whisper-turbo
github_2023
FL33TW00D
typescript
SessionManager.loadModel
public async loadModel( selectedModel: AvailableModels, onLoaded: (result: any) => void, onProgress: (progress: number) => void ): Promise<Result<InferenceSession, Error>> { const creationResult = await this.createSession( true, selectedModel, onPr...
/** * Loads a model and returns a Session instance. * @param selectedModel - The model to load. * @param onLoaded - A callback that is called when the model is loaded. * @returns A Promise that resolves with a Session instance. * */
https://github.com/FL33TW00D/whisper-turbo/blob/54916ad654a24b6424ca2052651dc384de7d66ed/src/sessionManager.ts#L15-L30
54916ad654a24b6424ca2052651dc384de7d66ed
whisper-turbo
github_2023
FL33TW00D
typescript
SessionManager.createSession
private async createSession( spawnWorker: boolean, selectedModel: AvailableModels, onProgress: (progress: number) => void ): Promise<Result<InferenceSession, Error>> { if (spawnWorker && typeof document !== "undefined") { const worker = new Worker( new URL...
/** * Creates a new session with the specified models. * * @param spawnWorker - Determines whether a Web Worker should be used for the session. * @param selectedModel - The model to use for the session. * @returns A Promise that resolves with a Session instance, or a Remote<Session> instance if...
https://github.com/FL33TW00D/whisper-turbo/blob/54916ad654a24b6424ca2052651dc384de7d66ed/src/sessionManager.ts#L40-L80
54916ad654a24b6424ca2052651dc384de7d66ed
evo.ninja
github_2023
agentcoinorg
typescript
getLastProcessedMessageIndex
function getLastProcessedMessageIndex(chunks: Chunk[]): number { const lastIdx = chunks.length - 1; // Nothing has been processed if (lastIdx < 0) { return -1; } // Return the message index of the last metadata return chunks[lastIdx].msgIdx; }
// Helpers
https://github.com/agentcoinorg/evo.ninja/blob/0fce6d4cef630976daf1a161cdb4881c280087ff/packages/agents/src/agent-core/llm/chat/ContextualizedChat.ts#L208-L218
0fce6d4cef630976daf1a161cdb4881c280087ff
evo.ninja
github_2023
agentcoinorg
typescript
InitPoetryFunction.getPythonDependencies
private async getPythonDependencies( workspace: Workspace, dir: string ): Promise<string[]> { const pythonFiles = (await workspace.readdir(dir)) .map((dirEntry) => dirEntry.name) .filter((file) => file.endsWith(".py")); let imports = []; for (const file of pythonFiles) { const f...
// does not search recursively
https://github.com/agentcoinorg/evo.ninja/blob/0fce6d4cef630976daf1a161cdb4881c280087ff/packages/agents/src/functions/InitPoetry.ts#L109-L135
0fce6d4cef630976daf1a161cdb4881c280087ff
evo.ninja
github_2023
agentcoinorg
typescript
InitPoetryFunction.parsePythonImports
private parsePythonImports(fileContent: string): string[] { const imports: string[] = []; const singleImportRegex = /^(?:import|from) ([a-zA-Z0-9_]+)(?: import [a-zA-Z0-9_*]+(?: as [a-zA-Z0-9_]+)?)?/gm; const multipleImportRegex = /^import ([a-zA-Z0-9_ ,]+)$/gm; const multipleFromImportRegex = ...
// does not handle relative imports or sub-module imports
https://github.com/agentcoinorg/evo.ninja/blob/0fce6d4cef630976daf1a161cdb4881c280087ff/packages/agents/src/functions/InitPoetry.ts#L138-L159
0fce6d4cef630976daf1a161cdb4881c280087ff
ant-design-web3
github_2023
ant-design
typescript
WalletConnectionError.constructor
constructor(public message: string) {}
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
https://github.com/ant-design/ant-design-web3/blob/e66ae31226134cc032054e454f749b912a2ed509/packages/solana/src/solana-provider/__tests__/connect-error.test.tsx#L37-L37
e66ae31226134cc032054e454f749b912a2ed509
ant-design-web3
github_2023
ant-design
typescript
App
const App: React.FC = () => { return ( <BitcoinWeb3ConfigProvider wallets={[XverseWallet(), UnisatWallet(), OkxWallet(), PhantomWallet()]} > <Connector modalProps={{ group: false, mode: 'simple', }} > <ConnectButton /> </Connector> </Bitc...
/** * The main application component that sets up the BitcoinWeb3ConfigProvider and Connector. * @returns {JSX.Element} The rendered application component. */
https://github.com/ant-design/ant-design-web3/blob/e66ae31226134cc032054e454f749b912a2ed509/packages/web3/src/bitcoin/demos/basic.tsx#L14-L29
e66ae31226134cc032054e454f749b912a2ed509
ant-design-web3
github_2023
ant-design
typescript
App
const App: React.FC = () => { return ( <BitcoinWeb3ConfigProvider> <Space size={16}> <NFTCard name="Bitcoin Puppet #2087" description="Vibing, thriving, and striving for world peace." address="53151380" tokenId={2087n} /> <NFTCard typ...
/** * The main application component that sets up the BitcoinWeb3ConfigProvider and displays NFT cards. * @returns {JSX.Element} The rendered application component. */
https://github.com/ant-design/ant-design-web3/blob/e66ae31226134cc032054e454f749b912a2ed509/packages/web3/src/bitcoin/demos/ordinals.tsx#L9-L29
e66ae31226134cc032054e454f749b912a2ed509
ant-design-web3
github_2023
ant-design
typescript
SendBitcoin
const SendBitcoin: React.FC = () => { const { sendTransfer, account } = useBitcoinWallet(); return account ? ( <Button onClick={async () => { try { // Don't send in main network!! await sendTransfer({ to: 'bc1pcdv3h6nuq705e3yk4pvdlqrcfchzvd9se9zwlhke3menvxlc58zshl0...
/** * Component to send Bitcoin transfer. * @returns {JSX.Element | null} The rendered component. */
https://github.com/ant-design/ant-design-web3/blob/e66ae31226134cc032054e454f749b912a2ed509/packages/web3/src/bitcoin/demos/send-transfer.tsx#L17-L42
e66ae31226134cc032054e454f749b912a2ed509
ant-design-web3
github_2023
ant-design
typescript
checkValue
function checkValue(orginInputValue: string, expectInputValue: string, expectAmount: bigint) { fireEvent.change(inputEle, { target: { value: orginInputValue }, }); expect(inputEle.getAttribute('value')).toBe(orginInputValue); expect(handleChange).toHaveBeenCalledWith({ token: m...
/** * check token amount value * first input some value and the input element should display the same value * then check onChange callback is called with correct amount * then blur the input element, when input value decimals is over token decimals, it should cut correctly */
https://github.com/ant-design/ant-design-web3/blob/e66ae31226134cc032054e454f749b912a2ed509/packages/web3/src/crypto-input/__tests__/index.test.tsx#L165-L181
e66ae31226134cc032054e454f749b912a2ed509
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
getContext
const getContext = (app: cdk.App): StackInput => { const params = stackInputSchema.parse(app.node.getAllContext()); return params; };
// CDK Context からパラメータを取得する場合
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/parameter.ts#L5-L8
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
checkEmailDomain
const checkEmailDomain = (email: string): boolean => { // メールアドレスの中の @ の数が1つでない場合は、常に許可しない if (email.split('@').length !== 2) { return false; } // メールアドレスのドメイン部分が、許可ドメインの"いずれか"と一致すれば許可する // それ以外の場合は、許可しない // (ALLOWED_SIGN_UP_EMAIL_DOMAINSが空の場合は、常に許可しない) const domain = email.split('@')[1]; return AL...
// メールアドレスのドメインを許可するかどうかを判定する
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/checkEmailDomain.ts#L10-L21
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
innerFindUseCaseByUseCaseId
const innerFindUseCaseByUseCaseId = async ( useCaseId: string ): Promise<UseCaseInTable | null> => { const useCaseInTable = await dynamoDbDocument.send( new QueryCommand({ TableName: USECASE_TABLE_NAME, IndexName: USECASE_ID_INDEX_NAME, KeyConditionExpression: '#useCaseId = :useCaseId ...
// useCaseId のユースケースを取得
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/useCaseBuilder/useCaseBuilderRepository.ts#L39-L64
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
innerFindUseCasesByUserId
const innerFindUseCasesByUserId = async ( userId: string, _exclusiveStartKey?: string ): Promise<{ useCases: UseCaseInTable[]; lastEvaluatedKey?: string }> => { const exclusiveStartKey = _exclusiveStartKey ? JSON.parse(Buffer.from(_exclusiveStartKey, 'base64').toString()) : undefined; const useCasesInTa...
// userId のユースケース一覧を取得
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/useCaseBuilder/useCaseBuilderRepository.ts#L67-L101
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
innerFindUseCasesByUseCaseIds
const innerFindUseCasesByUseCaseIds = async ( useCaseIds: string[] ): Promise<UseCaseInTable[]> => { const useCasesInTable: UseCaseInTable[] = []; for (const useCaseId of useCaseIds) { const useCaseInTable = await innerFindUseCaseByUseCaseId(useCaseId); if (useCaseInTable) { useCasesInTable.push(u...
// useCaseId の配列からユースケース一覧を取得
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/useCaseBuilder/useCaseBuilderRepository.ts#L104-L118
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
innerFindCommonsByUserIdAndDataType
const innerFindCommonsByUserIdAndDataType = async ( userId: string, dataTypePrefix: string ): Promise<UseCaseCommon[]> => { const commons = await dynamoDbDocument.send( new QueryCommand({ TableName: USECASE_TABLE_NAME, KeyConditionExpression: '#id = :id and begins_with(#dataType, :dataType...
// userId の特定のデータタイプ (お気に入り・利用履歴) 一覧を取得 (全取得)
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/useCaseBuilder/useCaseBuilderRepository.ts#L121-L143
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
innerFindCommonsByUserIdAndDataTypePagniation
const innerFindCommonsByUserIdAndDataTypePagniation = async ( userId: string, dataTypePrefix: string, _exclusiveStartKey?: string ): Promise<{ commons: UseCaseCommon[]; lastEvaluatedKey?: string }> => { const exclusiveStartKey = _exclusiveStartKey ? JSON.parse(Buffer.from(_exclusiveStartKey, 'base64').toStr...
// userId の特定のデータタイプ (お気に入り・利用履歴) 一覧を取得 (ページネーション対応)
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/useCaseBuilder/useCaseBuilderRepository.ts#L146-L179
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
innerFindCommonsByUseCaseId
const innerFindCommonsByUseCaseId = async ( useCaseId: string ): Promise<UseCaseCommon[]> => { const commons = await dynamoDbDocument.send( new QueryCommand({ TableName: USECASE_TABLE_NAME, IndexName: USECASE_ID_INDEX_NAME, KeyConditionExpression: '#useCaseId = :useCaseId', ExpressionAtt...
// useCaseId に関連する全てのデータ (本体・お気に入り・利用履歴) 一覧を取得
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/useCaseBuilder/useCaseBuilderRepository.ts#L182-L200
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
convertS3UriToUrl
const convertS3UriToUrl = (s3Uri: string, region: string): string => { const result = /^s3:\/\/(?<bucketName>.+?)\/(?<prefix>.+)/.exec(s3Uri); if (result) { const groups = result?.groups as { bucketName: string; prefix: string; }; return `https://s3.${region}.amazonaws.com/${groups.bucketNam...
// s3://<BUCKET>/<PREFIX> から https://s3.<REGION>.amazonaws.com/<BUCKET>/<PREFIX> に変換する
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/utils/bedrockAgentApi.ts#L42-L52
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
encodeUrlString
const encodeUrlString = (str: string): string => { try { return encodeURIComponent(str); } catch (e) { console.error('Failed to URL-encode string:', e); return str; } };
// 文字列をURL-encodeする
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/utils/bedrockAgentApi.ts#L55-L62
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
assumeRole
const assumeRole = async (crossAccountBedrockRoleArn: string) => { const stsClient = new STSClient({ region: process.env.MODEL_REGION }); const command = new AssumeRoleCommand({ RoleArn: crossAccountBedrockRoleArn, RoleSessionName: 'BedrockApiAccess', }); try { const response = await stsClient.send...
// STSから一時的な認証情報を取得する関数
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/utils/bedrockApi.ts#L25-L47
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
initBedrockClient
const initBedrockClient = async () => { // CROSS_ACCOUNT_BEDROCK_ROLE_ARN が設定されているかチェック if (process.env.CROSS_ACCOUNT_BEDROCK_ROLE_ARN) { // STS から一時的な認証情報を取得してクライアントを初期化 const tempCredentials = await assumeRole( process.env.CROSS_ACCOUNT_BEDROCK_ROLE_ARN ); if ( !tempCredentials.access...
// BedrockRuntimeClient を初期化するこの関数は、通常では単純に BedrockRuntimeClient を環境変数で指定されたリージョンで初期化します。
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/utils/bedrockApi.ts#L54-L84
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
convertS3UriToUrl
const convertS3UriToUrl = (s3Uri: string, region: string): string => { const result = /^s3:\/\/(?<bucketName>.+?)\/(?<prefix>.+)/.exec(s3Uri); if (result) { const groups = result?.groups as { bucketName: string; prefix: string; }; return `https://s3.${region}.amazonaws.com/${groups.bucketNam...
// s3://<BUCKET>/<PREFIX> から https://s3.<REGION>.amazonaws.com/<BUCKET>/<PREFIX> に変換する
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/utils/bedrockKbApi.ts#L32-L42
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
encodeUrlString
const encodeUrlString = (str: string): string => { try { return encodeURIComponent(str); } catch (e) { console.error('Failed to URL-encode string:', e); return str; } };
// 文字列をURL-encodeする
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/utils/bedrockKbApi.ts#L45-L52
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
createGuardrailConfig
const createGuardrailConfig = (): GuardrailConverseConfigParams | undefined => { if ( process.env.GUARDRAIL_IDENTIFIER !== undefined && process.env.GUARDRAIL_VERSION !== undefined ) { return { guardrailIdentifier: process.env.GUARDRAIL_IDENTIFIER, guardrailVersion: process.env.GUARDRAIL_VERS...
// guardrail 設定
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/utils/models.ts#L140-L153
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
normalizeId
function normalizeId(id: string): string { if (!id) return id; const rule = idTransformationRules.find((rule) => id.match(rule.pattern)); const ret = rule ? rule.replacement : id; return ret; }
// ID変換
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/utils/models.ts#L178-L183
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
createConverseCommandInput
const createConverseCommandInput = ( messages: UnrecordedMessage[], id: string, modelId: string, defaultConverseInferenceParams: ConverseInferenceParams, usecaseConverseInferenceParams: UsecaseConverseInferenceParams ) => { // system role で渡された文字列を、システムプロンプトに設定 const system = messages.find((message) => me...
// API の呼び出しや、出力から文字列を抽出、などの処理
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/utils/models.ts#L187-L277
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
createConverseCommandInputWithoutSystemContext
const createConverseCommandInputWithoutSystemContext = ( messages: UnrecordedMessage[], id: string, modelId: string, defaultConverseInferenceParams: ConverseInferenceParams, usecaseConverseInferenceParams: UsecaseConverseInferenceParams ) => { // system が利用できないので、system も user として入れる。 messages = messages....
// システムプロンプトに対応していないモデル用の関数
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/utils/models.ts#L283-L315
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
createConverseStreamCommandInput
const createConverseStreamCommandInput = ( messages: UnrecordedMessage[], id: string, modelId: string, defaultParams: ConverseInferenceParams, usecaseParams: UsecaseConverseInferenceParams ): ConverseStreamCommandInput => { const converseCommandInput = createConverseCommandInput( messages, id, m...
// ConverseStreamCommandInput は、同じ構造を持つため「createConverseCommandInput」で作成したインプットをそのまま利用する。
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/utils/models.ts#L318-L337
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
createConverseStreamCommandInputWithoutSystemContext
const createConverseStreamCommandInputWithoutSystemContext = ( messages: UnrecordedMessage[], id: string, modelId: string, defaultParams: ConverseInferenceParams, usecaseParams: UsecaseConverseInferenceParams ): ConverseStreamCommandInput => { const converseCommandInput = createConverseCommandInputWithoutSy...
// システムプロンプトに対応していないモデル用の関数
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lambda/utils/models.ts#L343-L362
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
Api.allowDownloadFile
allowDownloadFile(bucketName: string) { this.getFileDownloadSignedUrlFunction.role?.addToPrincipalPolicy( new PolicyStatement({ effect: Effect.ALLOW, resources: [ `arn:aws:s3:::${bucketName}`, `arn:aws:s3:::${bucketName}/*`, ], actions: ['s3:GetBucket*', 's3...
// Bucket 名を指定してダウンロード可能にする
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/cdk/lib/construct/api.ts#L775-L786
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
extractChatId
const extractChatId = (path: string): string | null => { const pattern = /\/chat\/(.+)/; const match = path.match(pattern); return match ? match[1] : null; };
// /chat/:chatId の形式から :chatId を返す
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/App.tsx#L45-L50
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
useChat
const useChat = (id: string, chatId?: string) => { const { chats, loading, getModelId, setModelId, setLoading, init, clear, restore, post, continueGeneration, retryGeneration, sendFeedback, updateSystemContext, getCurrentSystemContext, pushMessage, popMe...
/** * チャットを操作する Hooks * @param id 画面の URI(状態の識別に利用) * @param systemContext * @param chatId * @returns */
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/hooks/useChat.ts#L758-L930
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
convertFile2UploadedFileType
const convertFile2UploadedFileType = (file: File): UploadedFileType => { const getFileType = (fileType: string) => { if (fileType.includes('image')) return 'image'; if (fileType.includes('video')) return 'video'; return 'file'; }; return { file, name: file.name, type: get...
// Convert JS File Object to UploadedFileType to handle file upload status
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/hooks/useFiles.ts#L51-L64
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
validateUploadedFiles
const validateUploadedFiles = async ( uploadedFiles: UploadedFileType[], fileLimit: FileLimit, accept: string[] ) => { let fileCount = 0; let imageFileCount = 0; let videoFileCount = 0; // filter は非同期関数が利用できないため先に評価を行う const isMimeSpoofedResults = await Promise.all( uploadedFile...
// Validated given uploadedFiles, return updated uploadedFiles (no side effect) and errorMessages
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/hooks/useFiles.ts#L67-L180
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
getMaxFileSizeMB
const getMaxFileSizeMB = (fileType: string) => { if (fileType.includes('image')) return fileLimit.maxImageFileSizeMB; if (fileType.includes('video')) return fileLimit.maxVideoFileSizeMB; return fileLimit.maxFileSizeMB; };
// ファイルサイズによるフィルタリング
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/hooks/useFiles.ts#L122-L126
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
checkFiles
const checkFiles = async ( id: string, fileLimit: FileLimit, accept: string[] ) => { // Get current files const currentUploadedFiles = get().uploadedFilesDict[id] ?? []; // Get updated error messages const { uploadedFiles: newUploadedFiles, errorMessages } = await validateUploadedFi...
// Refresh error messages
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/hooks/useFiles.ts#L183-L201
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
uploadFiles
const uploadFiles = async ( id: string, files: File[], fileLimit: FileLimit, accept: string[] ) => { // Get File const currentUploadedFiles = get().uploadedFilesDict[id] ?? []; const newUploadedFiles: UploadedFileType[] = [ ...currentUploadedFiles, ...files.map(convertFile2Uplo...
// Handle File Uploads
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/hooks/useFiles.ts#L204-L272
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
deleteUploadedFile
const deleteUploadedFile = async ( id: string, fileUrl: string, fileLimit: FileLimit, accept: string[] ) => { const baseUrl = extractBaseURL(fileUrl); const findTargetIndex = () => get().uploadedFilesDict[id].findIndex((file) => file.s3Url === baseUrl); let targetIndex = findTargetI...
// Delete Uploaded File
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/hooks/useFiles.ts#L275-L318
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
getFileDownloadSignedUrl
const getFileDownloadSignedUrl = async ( s3Url: string, cacheBase64?: boolean ) => { const url = await api.getFileDownloadSignedUrl(s3Url); // Base64 キャッシュが要求された場合 if (cacheBase64) { try { const response = await fetch(url); const blob = await response.blob(); const r...
// getFileDownloadSignedUrl を useFileApi から移動し、Base64 キャッシュ機能を追加
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/hooks/useFiles.ts#L321-L352
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
useHttp
const useHttp = () => { return { api, /** * GET Request * Implemented with SWR * @param url * @returns */ // eslint-disable-next-line @typescript-eslint/no-explicit-any get: <Data = any, Error = any>( url: string | null, config?: SWRConfiguration ) => { /...
/** * Hooks for Http Request * @returns */
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/hooks/useHttp.ts#L31-L141
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
uniqueKeyOfItem
const uniqueKeyOfItem = (item: RetrieveResultItem): string => { const pageNumber = item.DocumentAttributes?.find( (a: DocumentAttribute) => a.Key === '_excerpt_page_number' )?.Value?.LongValue ?? ''; const uri = item.DocumentURI; return `${uri}_${pageNumber}`; };
// 同一のドキュメントとみなす Key 値
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/hooks/useRag.ts#L12-L19
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
convertS3UriToUrl
const convertS3UriToUrl = (s3Uri: string, region: string): string => { const result = /^s3:\/\/(?<bucketName>.+?)\/(?<prefix>.+)/.exec(s3Uri); if (!result) { return s3Uri; } const groups = result?.groups as { bucketName: string; prefix: string; }; return `https://s3.${region}.amazonaws.com/${...
// s3://<BUCKET>/<PREFIX> から https://s3.<REGION>.amazonaws.com/<BUCKET>/<PREFIX> に変換する
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/hooks/useRagKnowledgeBase.ts#L16-L29
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
generative-ai-use-cases-jp
github_2023
aws-samples
typescript
encodeRFC3986URI
const encodeRFC3986URI = (uri: string) => { return encodeURI(uri).replace( /[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}` ); };
// RFC3986 Encoding
https://github.com/aws-samples/generative-ai-use-cases-jp/blob/e4828a5509a9022b4d9e517c9a47c8688cfd0ccd/packages/web/src/utils/URLUtils.ts#L3-L8
e4828a5509a9022b4d9e517c9a47c8688cfd0ccd
Slack
github_2023
qiwentaidi
typescript
LoadConfig
async function LoadConfig() { let stat = await CheckFileStat(global.PATH.homedir + "/slack/config.json") if (!stat) { var data = { proxy: global.proxy, space: global.space, jsfind: global.jsfind, webscan: global.webscan, database: global.database }; await SaveDataToFile(data); } else { let result = aw...
// 加载本地配置信息
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/frontend/src/config.ts#L55-L72
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Buffer.constructor
constructor() {}
// Constructor of Buffer
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/bytes.ts#L21-L21
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Buffer.Write
public Write(data: Uint8Array): Buffer { return this; }
/** * Write appends the given data to the buffer. * @example * ```javascript * const bytes = require('nuclei/bytes'); * const buffer = new bytes.Buffer(); * buffer.Write([1, 2, 3]); * ``` */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/bytes.ts#L31-L33
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Buffer.WriteString
public WriteString(data: string): Buffer { return this; }
/** * WriteString appends the given string data to the buffer. * @example * ```javascript * const bytes = require('nuclei/bytes'); * const buffer = new bytes.Buffer(); * buffer.WriteString('hello'); * ``` */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/bytes.ts#L45-L47
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Buffer.Bytes
public Bytes(): Uint8Array { return new Uint8Array(8); }
/** * Bytes returns the byte representation of the buffer. * @example * ```javascript * const bytes = require('nuclei/bytes'); * const buffer = new bytes.Buffer(); * buffer.WriteString('hello'); * log(buffer.Bytes()); * ``` */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/bytes.ts#L60-L62
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Buffer.String
public String(): string { return ""; }
/** * String returns the string representation of the buffer. * @example * ```javascript * const bytes = require('nuclei/bytes'); * const buffer = new bytes.Buffer(); * buffer.WriteString('hello'); * log(buffer.String()); * ``` */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/bytes.ts#L75-L77
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Buffer.Len
public Len(): number { return 0; }
/** * Len returns the length of the buffer. * @example * ```javascript * const bytes = require('nuclei/bytes'); * const buffer = new bytes.Buffer(); * buffer.WriteString('hello'); * log(buffer.Len()); * ``` */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/bytes.ts#L90-L92
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Buffer.Hex
public Hex(): string { return ""; }
/** * Hex returns the hex representation of the buffer. * @example * ```javascript * const bytes = require('nuclei/bytes'); * const buffer = new bytes.Buffer(); * buffer.WriteString('hello'); * log(buffer.Hex()); * ``` */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/bytes.ts#L105-L107
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Buffer.Hexdump
public Hexdump(): string { return ""; }
/** * Hexdump returns the hexdump representation of the buffer. * @example * ```javascript * const bytes = require('nuclei/bytes'); * const buffer = new bytes.Buffer(); * buffer.WriteString('hello'); * log(buffer.Hexdump()); * ``` */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/bytes.ts#L120-L122
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Buffer.Pack
public Pack(formatStr: string, msg: any): void { return; }
/** * Pack uses structs.Pack and packs given data and appends it to the buffer. * it packs the data according to the given format. * @example * ```javascript * const bytes = require('nuclei/bytes'); * const buffer = new bytes.Buffer(); * buffer.Pack('I', 123); * ``` */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/bytes.ts#L135-L137
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
GoConsolePrinter.constructor
constructor() {}
// Constructor of GoConsolePrinter
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/goconsole.ts#L18-L18
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
GoConsolePrinter.Log
public Log(msg: string): void { return; }
/** * Log Method */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/goconsole.ts#L22-L24
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
GoConsolePrinter.Warn
public Warn(msg: string): void { return; }
/** * Warn Method */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/goconsole.ts#L30-L32
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
GoConsolePrinter.Error
public Error(msg: string): void { return; }
/** * Error Method */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/goconsole.ts#L38-L40
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
IKEMessage.constructor
constructor() {}
// Constructor of IKEMessage
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/ikev2.ts#L52-L52
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
IKEMessage.AppendPayload
public AppendPayload(payload: any): void { return; }
/** * AppendPayload appends a payload to the IKE message * payload can be any of the payloads like IKENotification, IKENonce, etc. * @example * ```javascript * const ikev2 = require('nuclei/ikev2'); * const message = new ikev2.IKEMessage(); * const nonce = new ikev2.IKENonce(); * nonce.N...
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/ikev2.ts#L65-L67
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
IKEMessage.Encode
public Encode(): Uint8Array | null { return null; }
/** * Encode encodes the final IKE message * @example * ```javascript * const ikev2 = require('nuclei/ikev2'); * const message = new ikev2.IKEMessage(); * const nonce = new ikev2.IKENonce(); * nonce.NonceData = [1, 2, 3]; * message.AppendPayload(nonce); * log(message.Encode()); *...
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/ikev2.ts#L82-L84
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.constructor
constructor(public domain: string, public controller?: string ) {}
// Constructor of Client
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/kerberos.ts#L90-L90
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.SetConfig
public SetConfig(cfg: Config): void { return; }
/** * SetConfig sets additional config for the kerberos client * Note: as of now ip and timeout overrides are only supported * in EnumerateUser due to fastdialer but can be extended to other methods currently * @example * ```javascript * const kerberos = require('nuclei/kerberos'); * const c...
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/kerberos.ts#L107-L109
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.EnumerateUser
public EnumerateUser(username: string): EnumerateUserResponse | null { return null; }
/** * EnumerateUser and attempt to get AS-REP hash by disabling PA-FX-FAST * @example * ```javascript * const kerberos = require('nuclei/kerberos'); * const client = new kerberos.Client('acme.com', 'kdc.acme.com'); * const resp = client.EnumerateUser('pdtm'); * log(resp); * ``` */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/kerberos.ts#L122-L124
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.GetServiceTicket
public GetServiceTicket(User: string): TGS | null { return null; }
/** * GetServiceTicket returns a TGS for a given user, password and SPN * @example * ```javascript * const kerberos = require('nuclei/kerberos'); * const client = new kerberos.Client('acme.com', 'kdc.acme.com'); * const resp = client.GetServiceTicket('pdtm', 'password', 'HOST/CLIENT1'); * lo...
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/kerberos.ts#L137-L139
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Config.constructor
constructor() {}
// Constructor of Config
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/kerberos.ts#L153-L153
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Config.SetIPAddress
public SetIPAddress(ip: string): Config | null { return null; }
/** * SetIPAddress sets the IP address for the kerberos client * @example * ```javascript * const kerberos = require('nuclei/kerberos'); * const cfg = new kerberos.Config(); * cfg.SetIPAddress('10.10.10.1'); * ``` */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/kerberos.ts#L163-L165
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Config.SetTimeout
public SetTimeout(timeout: number): Config | null { return null; }
/** * SetTimeout sets the RW timeout for the kerberos client * @example * ```javascript * const kerberos = require('nuclei/kerberos'); * const cfg = new kerberos.Config(); * cfg.SetTimeout(5); * ``` */
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/kerberos.ts#L177-L179
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.constructor
constructor(public ldapUrl: string, public realm: string, public config?: Config ) {}
// Constructor of Client
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/ldap.ts#L198-L198
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.FindADObjects
public FindADObjects(filter: string): SearchResult | null { return null; }
/** * FindADObjects finds AD objects based on a filter * and returns them as a list of ADObject * @example * ```javascript * const ldap = require('nuclei/ldap'); * const client = new ldap.Client('ldap://ldap.example.com', 'acme.com'); * const users = client.FindADObjects(ldap.FilterIsPerson)...
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/ldap.ts#L212-L214
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.GetADUsers
public GetADUsers(): SearchResult | null { return null; }
/** * GetADUsers returns all AD users * using FilterIsPerson filter query * @example * ```javascript * const ldap = require('nuclei/ldap'); * const client = new ldap.Client('ldap://ldap.example.com', 'acme.com'); * const users = client.GetADUsers(); * log(to_json(users)); * ``` *...
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/ldap.ts#L228-L230
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.GetADActiveUsers
public GetADActiveUsers(): SearchResult | null { return null; }
/** * GetADActiveUsers returns all AD users * using FilterIsPerson and FilterAccountEnabled filter query * @example * ```javascript * const ldap = require('nuclei/ldap'); * const client = new ldap.Client('ldap://ldap.example.com', 'acme.com'); * const users = client.GetADActiveUsers(); *...
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/ldap.ts#L244-L246
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.GetADUserWithNeverExpiringPasswords
public GetADUserWithNeverExpiringPasswords(): SearchResult | null { return null; }
/** * GetAdUserWithNeverExpiringPasswords returns all AD users * using FilterIsPerson and FilterDontExpirePassword filter query * @example * ```javascript * const ldap = require('nuclei/ldap'); * const client = new ldap.Client('ldap://ldap.example.com', 'acme.com'); * const users = client.Ge...
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/ldap.ts#L260-L262
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.GetADUserTrustedForDelegation
public GetADUserTrustedForDelegation(): SearchResult | null { return null; }
/** * GetADUserTrustedForDelegation returns all AD users that are trusted for delegation * using FilterIsPerson and FilterTrustedForDelegation filter query * @example * ```javascript * const ldap = require('nuclei/ldap'); * const client = new ldap.Client('ldap://ldap.example.com', 'acme.com'); ...
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/ldap.ts#L276-L278
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.GetADUserWithPasswordNotRequired
public GetADUserWithPasswordNotRequired(): SearchResult | null { return null; }
/** * GetADUserWithPasswordNotRequired returns all AD users that do not require a password * using FilterIsPerson and FilterPasswordNotRequired filter query * @example * ```javascript * const ldap = require('nuclei/ldap'); * const client = new ldap.Client('ldap://ldap.example.com', 'acme.com'); ...
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/ldap.ts#L292-L294
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.GetADGroups
public GetADGroups(): SearchResult | null { return null; }
/** * GetADGroups returns all AD groups * using FilterIsGroup filter query * @example * ```javascript * const ldap = require('nuclei/ldap'); * const client = new ldap.Client('ldap://ldap.example.com', 'acme.com'); * const groups = client.GetADGroups(); * log(to_json(groups)); * ``` ...
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/ldap.ts#L308-L310
be1155d9ae7c179e92054971d51e0e3da8d36b28
Slack
github_2023
qiwentaidi
typescript
Client.GetADDCList
public GetADDCList(): SearchResult | null { return null; }
/** * GetADDCList returns all AD domain controllers * using FilterIsComputer, FilterAccountEnabled and FilterServerTrustAccount filter query * @example * ```javascript * const ldap = require('nuclei/ldap'); * const client = new ldap.Client('ldap://ldap.example.com', 'acme.com'); * const dcs ...
https://github.com/qiwentaidi/Slack/blob/be1155d9ae7c179e92054971d51e0e3da8d36b28/lib/nuclei/pkg/js/generated/ts/ldap.ts#L324-L326
be1155d9ae7c179e92054971d51e0e3da8d36b28