Skip to content

Commit

Permalink
Switch test runner to SWC (langchain-ai#2761)
Browse files Browse the repository at this point in the history
* Switch test runner to SWC

* Skip mac test

* Fix typo
  • Loading branch information
jacoblee93 authored Sep 30, 2023
1 parent c3ba4e6 commit f2bdd57
Show file tree
Hide file tree
Showing 32 changed files with 792 additions and 557 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ jobs:
os: [ubuntu-latest]
node-version: [18.x, 19.x, 20.x]
# See Node.js release schedule at https://nodejs.org/en/about/releases/
include:
# include:
# - os: windows-latest
# node-version: 20.x
- os: macos-latest
node-version: 20.x
# - os: macos-latest
# node-version: 20.x
runs-on: ${{ matrix.os }}
env:
PUPPETEER_SKIP_DOWNLOAD: "true"
Expand Down
2 changes: 1 addition & 1 deletion langchain/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
"^.+\\.m?[tj]sx?$": ["ts-jest", { useESM: true }],
'^.+\\.tsx?$': ['@swc/jest'],
},
transformIgnorePatterns: [
"/node_modules/",
Expand Down
2 changes: 2 additions & 0 deletions langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@
"@smithy/util-utf8": "^2.0.0",
"@supabase/postgrest-js": "^1.1.1",
"@supabase/supabase-js": "^2.10.0",
"@swc/core": "^1.3.90",
"@swc/jest": "^0.2.29",
"@tensorflow-models/universal-sentence-encoder": "^1.3.3",
"@tensorflow/tfjs-backend-cpu": "^3",
"@tensorflow/tfjs-converter": "^3.6.0",
Expand Down
48 changes: 24 additions & 24 deletions langchain/src/agents/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export {
Agent,
AgentArgs,
type AgentArgs,
BaseSingleActionAgent,
LLMSingleActionAgent,
LLMSingleActionAgentInput,
OutputParserArgs,
type LLMSingleActionAgentInput,
type OutputParserArgs,
} from "./agent.js";
export {
JsonToolkit,
OpenApiToolkit,
RequestsToolkit,
VectorStoreInfo,
type VectorStoreInfo,
VectorStoreRouterToolkit,
VectorStoreToolkit,
ZapierToolKit,
Expand All @@ -22,53 +22,53 @@ export {
export { Toolkit } from "./toolkits/base.js";
export {
ChatAgent,
ChatAgentInput,
ChatCreatePromptArgs,
type ChatAgentInput,
type ChatCreatePromptArgs,
} from "./chat/index.js";
export { ChatAgentOutputParser } from "./chat/outputParser.js";
export {
ChatConversationalAgent,
ChatConversationalAgentInput,
ChatConversationalCreatePromptArgs,
type ChatConversationalAgentInput,
type ChatConversationalCreatePromptArgs,
} from "./chat_convo/index.js";
export {
ChatConversationalAgentOutputParser,
ChatConversationalAgentOutputParserArgs,
type ChatConversationalAgentOutputParserArgs,
ChatConversationalAgentOutputParserWithRetries,
ChatConversationalAgentOutputParserFormatInstructionsOptions,
type ChatConversationalAgentOutputParserFormatInstructionsOptions,
} from "./chat_convo/outputParser.js";
export { AgentExecutor, AgentExecutorInput } from "./executor.js";
export { AgentExecutor, type AgentExecutorInput } from "./executor.js";
export {
initializeAgentExecutor,
initializeAgentExecutorWithOptions,
InitializeAgentExecutorOptions,
type InitializeAgentExecutorOptions,
} from "./initialize.js";
export {
ZeroShotAgent,
ZeroShotAgentInput,
ZeroShotCreatePromptArgs,
type ZeroShotAgentInput,
type ZeroShotCreatePromptArgs,
} from "./mrkl/index.js";
export { ZeroShotAgentOutputParser } from "./mrkl/outputParser.js";
export {
AgentActionOutputParser,
AgentInput,
SerializedAgent,
SerializedAgentT,
SerializedZeroShotAgent,
StoppingMethod,
type AgentInput,
type SerializedAgent,
type SerializedAgentT,
type SerializedZeroShotAgent,
type StoppingMethod,
} from "./types.js";
export {
StructuredChatAgent,
StructuredChatAgentInput,
StructuredChatCreatePromptArgs,
type StructuredChatAgentInput,
type StructuredChatCreatePromptArgs,
} from "./structured_chat/index.js";
export {
StructuredChatOutputParser,
StructuredChatOutputParserArgs,
type StructuredChatOutputParserArgs,
StructuredChatOutputParserWithRetries,
} from "./structured_chat/outputParser.js";
export {
OpenAIAgent,
OpenAIAgentInput,
OpenAIAgentCreatePromptArgs,
type OpenAIAgentInput,
type OpenAIAgentCreatePromptArgs,
} from "./openai/index.js";
4 changes: 2 additions & 2 deletions langchain/src/agents/toolkits/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export {
createOpenApiAgent,
} from "./openapi/openapi.js";
export {
VectorStoreInfo,
type VectorStoreInfo,
VectorStoreToolkit,
VectorStoreRouterToolkit,
createVectorStoreAgent,
Expand All @@ -15,6 +15,6 @@ export { ZapierToolKit } from "./zapier/zapier.js";
export { createRetrieverTool } from "./conversational_retrieval/tool.js";
export {
createConversationalRetrievalAgent,
ConversationalRetrievalAgentOptions,
type ConversationalRetrievalAgentOptions,
} from "./conversational_retrieval/openai_functions.js";
export { OpenAIAgentTokenBufferMemory } from "./conversational_retrieval/token_buffer_memory.js";
12 changes: 6 additions & 6 deletions langchain/src/callbacks/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export {
BaseCallbackHandler,
CallbackHandlerMethods,
BaseCallbackHandlerInput,
NewTokenIndices,
type CallbackHandlerMethods,
type BaseCallbackHandlerInput,
type NewTokenIndices,
} from "./base.js";

export { Run, RunType, BaseTracer } from "./handlers/tracer.js";
export { type Run, type RunType, BaseTracer } from "./handlers/tracer.js";

export { ConsoleCallbackHandler } from "./handlers/console.js";

Expand All @@ -26,8 +26,8 @@ export {
CallbackManagerForChainRun,
CallbackManagerForLLMRun,
CallbackManagerForToolRun,
CallbackManagerOptions,
Callbacks,
type CallbackManagerOptions,
type Callbacks,
TraceGroup,
traceAsGroup,
} from "./manager.js";
Expand Down
59 changes: 33 additions & 26 deletions langchain/src/chains/index.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,65 @@
export { BaseChain, ChainInputs } from "./base.js";
export { LLMChain, LLMChainInput } from "./llm_chain.js";
export { APIChain, APIChainInput, APIChainOptions } from "./api/api_chain.js";
export { BaseChain, type ChainInputs } from "./base.js";
export { LLMChain, type LLMChainInput } from "./llm_chain.js";
export {
APIChain,
type APIChainInput,
type APIChainOptions,
} from "./api/api_chain.js";
export { ConversationChain } from "./conversation.js";
export {
SequentialChain,
SequentialChainInput,
type SequentialChainInput,
SimpleSequentialChain,
SimpleSequentialChainInput,
type SimpleSequentialChainInput,
} from "./sequential_chain.js";
export {
StuffDocumentsChain,
StuffDocumentsChainInput,
type StuffDocumentsChainInput,
MapReduceDocumentsChain,
MapReduceDocumentsChainInput,
type MapReduceDocumentsChainInput,
RefineDocumentsChain,
RefineDocumentsChainInput,
type RefineDocumentsChainInput,
} from "./combine_docs_chain.js";
export {
ChatVectorDBQAChain,
ChatVectorDBQAChainInput,
type ChatVectorDBQAChainInput,
} from "./chat_vector_db_chain.js";
export {
AnalyzeDocumentChain,
AnalyzeDocumentChainInput,
type AnalyzeDocumentChainInput,
} from "./analyze_documents_chain.js";
export { VectorDBQAChain, VectorDBQAChainInput } from "./vector_db_qa.js";
export { VectorDBQAChain, type VectorDBQAChainInput } from "./vector_db_qa.js";
export {
loadQAChain,
QAChainParams,
type QAChainParams,
loadQAStuffChain,
StuffQAChainParams,
type StuffQAChainParams,
loadQAMapReduceChain,
MapReduceQAChainParams,
type MapReduceQAChainParams,
loadQARefineChain,
RefineQAChainParams,
type RefineQAChainParams,
} from "./question_answering/load.js";
export {
loadSummarizationChain,
SummarizationChainParams,
type SummarizationChainParams,
} from "./summarization/load.js";
export {
ConversationalRetrievalQAChain,
ConversationalRetrievalQAChainInput,
type ConversationalRetrievalQAChainInput,
} from "./conversational_retrieval_chain.js";
export { RetrievalQAChain, RetrievalQAChainInput } from "./retrieval_qa.js";
export {
ConstitutionalChainInput,
RetrievalQAChain,
type RetrievalQAChainInput,
} from "./retrieval_qa.js";
export {
type ConstitutionalChainInput,
ConstitutionalChain,
} from "./constitutional_ai/constitutional_chain.js";
export {
ConstitutionalPrinciple,
PRINCIPLES,
} from "./constitutional_ai/constitutional_principle.js";
export {
export type {
SerializedLLMChain,
SerializedSequentialChain,
SerializedSimpleSequentialChain,
Expand All @@ -68,27 +75,27 @@ export {
export { OpenAIModerationChain } from "./openai_moderation.js";
export {
MultiRouteChain,
MultiRouteChainInput,
type MultiRouteChainInput,
RouterChain,
} from "./router/multi_route.js";
export {
LLMRouterChain,
LLMRouterChainInput,
RouterOutputSchema,
type LLMRouterChainInput,
type RouterOutputSchema,
} from "./router/llm_router.js";
export { MultiPromptChain } from "./router/multi_prompt.js";
export { MultiRetrievalQAChain } from "./router/multi_retrieval_qa.js";
export { TransformChain, TransformChainFields } from "./transform.js";
export { TransformChain, type TransformChainFields } from "./transform.js";
export {
createExtractionChain,
createExtractionChainFromZod,
} from "./openai_functions/extraction.js";
export {
TaggingChainOptions,
type TaggingChainOptions,
createTaggingChain,
createTaggingChainFromZod,
} from "./openai_functions/tagging.js";
export {
OpenAPIChainOptions,
type OpenAPIChainOptions,
createOpenAPIChain,
} from "./openai_functions/openapi.js";
6 changes: 3 additions & 3 deletions langchain/src/chains/openai_functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ export {
createExtractionChainFromZod,
} from "./extraction.js";
export {
TaggingChainOptions,
type TaggingChainOptions,
createTaggingChain,
createTaggingChainFromZod,
} from "./tagging.js";
export { OpenAPIChainOptions, createOpenAPIChain } from "./openapi.js";
export { type OpenAPIChainOptions, createOpenAPIChain } from "./openapi.js";
export {
StructuredOutputChainInput,
type StructuredOutputChainInput,
createStructuredOutputChain,
createStructuredOutputChainFromZod,
} from "./structured_output.js";
2 changes: 1 addition & 1 deletion langchain/src/chains/query_constructor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { BaseLanguageModel } from "../../base_language/index.js";
import { AsymmetricStructuredOutputParser } from "../../output_parsers/structured.js";
import { AttributeInfo } from "../../schema/query_constructor.js";

export { QueryTransformer, TraverseType };
export { QueryTransformer, type TraverseType };
export {
DEFAULT_EXAMPLES,
DEFAULT_PREFIX,
Expand Down
2 changes: 1 addition & 1 deletion langchain/src/chat_models/googlevertexai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class ChatGoogleVertexAI extends BaseChatGoogleVertexAI<GoogleAuthOptions
}
}

export {
export type {
ChatExample,
GoogleVertexAIChatAuthor,
GoogleVertexAIChatInput,
Expand Down
2 changes: 1 addition & 1 deletion langchain/src/chat_models/googlevertexai/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ChatGoogleVertexAI extends BaseChatGoogleVertexAI<WebGoogleAuthOpti
}
}

export {
export type {
ChatExample,
GoogleVertexAIChatAuthor,
GoogleVertexAIChatInput,
Expand Down
2 changes: 1 addition & 1 deletion langchain/src/chat_models/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { BaseFunctionCallOptions } from "../base_language/index.js";
import { NewTokenIndices } from "../callbacks/base.js";
import { wrapOpenAIClientError } from "../util/openai.js";

export { AzureOpenAIInput, OpenAICallOptions, OpenAIChatInput };
export type { AzureOpenAIInput, OpenAICallOptions, OpenAIChatInput };

interface TokenUsage {
completionTokens?: number;
Expand Down
6 changes: 3 additions & 3 deletions langchain/src/experimental/autogpt/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { AutoGPTPrompt, AutoGPTPromptInput } from "./prompt.js";
export { AutoGPTPrompt, type AutoGPTPromptInput } from "./prompt.js";

export { AutoGPTOutputParser, preprocessJsonInput } from "./output_parser.js";

export { AutoGPT, AutoGPTInput } from "./agent.js";
export { AutoGPT, type AutoGPTInput } from "./agent.js";

export { AutoGPTAction } from "./schema.js";
export type { AutoGPTAction } from "./schema.js";
2 changes: 1 addition & 1 deletion langchain/src/experimental/babyagi/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { TaskCreationChain } from "./task_creation.js";
export { TaskExecutionChain } from "./task_execution.js";
export { TaskPrioritizationChain } from "./task_prioritization.js";
export { BabyAGI, Task, BabyAGIInputs } from "./agent.js";
export { BabyAGI, type Task, type BabyAGIInputs } from "./agent.js";
8 changes: 4 additions & 4 deletions langchain/src/experimental/plan_and_execute/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ export {
BasePlanner,
BaseStepContainer,
BaseStepExecutor,
StepAction,
StepResult,
Step,
Plan,
type StepAction,
type StepResult,
type Step,
type Plan,
ListStepContainer,
LLMPlanner,
ChainStepExecutor,
Expand Down
2 changes: 1 addition & 1 deletion langchain/src/llms/openai-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { promptLayerTrackRequest } from "../util/prompt-layer.js";
import { BaseLLMParams, LLM } from "./base.js";
import { wrapOpenAIClientError } from "../util/openai.js";

export { AzureOpenAIInput, OpenAIChatInput };
export { type AzureOpenAIInput, type OpenAIChatInput };
/**
* Interface that extends the OpenAICallOptions interface and includes an
* optional promptIndex property. It represents the options that can be
Expand Down
2 changes: 1 addition & 1 deletion langchain/src/llms/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { BaseLLM, BaseLLMParams } from "./base.js";
import { OpenAIChat } from "./openai-chat.js";
import { wrapOpenAIClientError } from "../util/openai.js";

export { AzureOpenAIInput, OpenAICallOptions, OpenAIInput };
export type { AzureOpenAIInput, OpenAICallOptions, OpenAIInput };

/**
* Interface for tracking token usage in OpenAI calls.
Expand Down
Loading

0 comments on commit f2bdd57

Please sign in to comment.