This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import config from "$config/mod.ts"; | |
import { | |
initializeAgentExecutorWithOptions, | |
} from "langchain/agents"; | |
import { BaseLanguageModel } from "langchain/base_language"; | |
import { CallbackManager, ConsoleCallbackHandler } from "langchain/callbacks"; | |
import { ChatOpenAI } from "langchain/chat_models/openai"; | |
import { Calculator } from "langchain/tools/calculator"; | |
import { BaseChatMessage } from "langchain/schema"; | |
import { assert } from "asserts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Redis } from "https://deno.land/x/upstash_redis@v1.20.2/mod.ts"; | |
import { StorageAdapter } from "~grammy/deps.ts"; | |
/** | |
* A storage adapter that uses upstash redis. | |
* @template T The type of the data to store. | |
* | |
* Implementation of StorageAdapter v2 were inspired by @grammyjs/storage-cloudflare | |
* @see {@link "https://github.com/grammyjs/storages/blob/main/packages/cloudflare/src/kv.ts"} | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When i hover `chatMembers`, i get: | |
``` | |
Argument of type 'Composer<ChatMembersContext>' is not assignable to parameter of type 'Middleware<GrammyContext>'. | |
Type 'Composer<ChatMembersContext>' is not assignable to type 'MiddlewareObj<GrammyContext>'. | |
The types returned by 'middleware()' are incompatible between these types. | |
Type 'MiddlewareFn<ChatMembersContext>' is not assignable to type 'MiddlewareFn<GrammyContext>'. | |
Types of parameters 'ctx' and 'ctx' are incompatible. | |
Type 'GrammyContext' is not assignable to type 'ChatMembersContext'. | |
Type 'SessionFlavor<GrammySession> & { conversation: ConversationControls; } & SessionFlavor<ConversationSessionData> & ChatMembersFlavor & Context & { ...; }' is not assignable to type 'ChatMembersContext'. | |
Type 'SessionFlavor<GrammySession> & { conversation: ConversationControls; } & SessionFlavor<ConversationSessionData> & ChatMembersFlavor & Context & { ...; }' is not assignable to type 'Context'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When i hover `chatMembers`, i get: | |
``` | |
Argument of type 'Composer<ChatMembersContext>' is not assignable to parameter of type 'Middleware<GrammyContext>'. | |
Type 'Composer<ChatMembersContext>' is not assignable to type 'MiddlewareObj<GrammyContext>'. | |
The types returned by 'middleware()' are incompatible between these types. | |
Type 'MiddlewareFn<ChatMembersContext>' is not assignable to type 'MiddlewareFn<GrammyContext>'. | |
Types of parameters 'ctx' and 'ctx' are incompatible. | |
Type 'GrammyContext' is not assignable to type 'ChatMembersContext'. | |
Type 'SessionFlavor<GrammySession> & { conversation: ConversationControls; } & SessionFlavor<ConversationSessionData> & ChatMembersFlavor & Context & { ...; }' is not assignable to type 'ChatMembersContext'. | |
Type 'SessionFlavor<GrammySession> & { conversation: ConversationControls; } & SessionFlavor<ConversationSessionData> & ChatMembersFlavor & Context & { ...; }' is not assignable to type 'Context'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The code below works for both gramjs in node and grm in deno | |
.... // other imports above | |
import ChannelParticipants = Api.channels.ChannelParticipants; | |
import ChatParticipant = Api.ChatParticipant; | |
import ChannelParticipant = Api.ChannelParticipant; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pages/Upload.tsx | |
import { getPresignedUrl } from "~/utils/files"; | |
export default function Upload() { | |
const uploadPhoto = async (e: React.ChangeEvent<HTMLInputElement>) => { | |
const file = e.target.files?.[0]; | |
const name = encodeURIComponent(file?.name as string); | |
const type = encodeURIComponent(file?.type as string); | |
const res = await getPresignedUrl({ name, type, size: "" + file!.size }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pages/Upload.tsx | |
import { getPresignedUrl } from "~/utils/files"; | |
export default function Upload() { | |
const uploadPhoto = async (e: React.ChangeEvent<HTMLInputElement>) => { | |
const file = e.target.files?.[0]; | |
const name = encodeURIComponent(file?.name as string); | |
const type = encodeURIComponent(file?.type as string); | |
const res = await getPresignedUrl({ name, type, size: "" + file!.size }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Chapter, | |
Options, | |
} from "epubgen/util/mod.ts"; | |
const date = new Date(); | |
date.setFullYear(2000); | |
export const optionsAlice: Options = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Column, DataTable } from '@saas-ui/react'; | |
interface ExampleData { | |
id: string | |
name: string | |
email: string | |
} | |
const columns: Column<ExampleData>[] = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Bot, Context, session, SessionFlavor } from 'grammy' | |
import { CustomSessionAdapter } from './session' | |
// This bot will collect some basic statistics about each chat. They can be | |
// retrieved with the `/stats` command. | |
// This is the data that will be saved per chat. | |
interface SessionData { | |
messages: number | |
edits: number |