Skip to content

Commit

Permalink
chore: lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Apr 8, 2024
1 parent 7fa51f6 commit 70a239f
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 61 deletions.
4 changes: 1 addition & 3 deletions examples/src/agents/quickstart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ const vectorstore = await MemoryVectorStore.fromDocuments(
);
const retriever = vectorstore.asRetriever();

const retrieverResult = await retriever.invoke(
"how to upload a dataset"
);
const retrieverResult = await retriever.invoke("how to upload a dataset");
console.log(retrieverResult[0]);

/*
Expand Down
5 changes: 4 additions & 1 deletion examples/src/callbacks/trace_groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export const run = async () => {
async (manager: CallbackManager, questions: string[]) => {
await chain.invoke({ question: questions[0] }, manager);
await chain.invoke({ question: questions[1] }, manager);
const finalResult = await chain.invoke({ question: questions[2] }, manager);
const finalResult = await chain.invoke(
{ question: questions[2] },
manager
);
return finalResult;
},
[
Expand Down
12 changes: 7 additions & 5 deletions examples/src/chains/llm_chain_cancellation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ try {
const res = await chain.invoke(
{ product: "colorful socks", signal: controller.signal },
{
callbacks: [{
handleLLMNewToken(token: string) {
process.stdout.write(token);
}
}],
callbacks: [
{
handleLLMNewToken(token: string) {
process.stdout.write(token);
},
},
],
}
);
} catch (e) {
Expand Down
19 changes: 11 additions & 8 deletions examples/src/chains/llm_chain_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ const prompt = PromptTemplate.fromTemplate(
const chain = new LLMChain({ llm: model, prompt });

// Call the chain with the inputs and a callback for the streamed tokens
const res = await chain.invoke({ product: "colorful socks" }, {
callbacks: [
{
handleLLMNewToken(token: string) {
process.stdout.write(token);
const res = await chain.invoke(
{ product: "colorful socks" },
{
callbacks: [
{
handleLLMNewToken(token: string) {
process.stdout.write(token);
},
},
},
]
});
],
}
);
console.log({ res });
// { res: { text: '\n\nKaleidoscope Socks' } }
25 changes: 12 additions & 13 deletions examples/src/chat/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,18 @@ export const run = async () => {
// Sending two separate prompts in parallel, receiving two responses back

const responseA = await chat.invoke([

new SystemMessage(
"You are a helpful assistant that translates English to French."
),
new HumanMessage(
"Translate this sentence from English to French. I love programming."
),
new SystemMessage(
"You are a helpful assistant that translates English to French."
),
new HumanMessage(
"Translate this sentence from English to French. I love artificial intelligence."
),
new SystemMessage(
"You are a helpful assistant that translates English to French."
),
new HumanMessage(
"Translate this sentence from English to French. I love programming."
),
new SystemMessage(
"You are a helpful assistant that translates English to French."
),
new HumanMessage(
"Translate this sentence from English to French. I love artificial intelligence."
),
]);

console.log(responseA);
Expand Down
4 changes: 3 additions & 1 deletion examples/src/experimental/babyagi/weather_with_tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ const babyAGI = BabyAGI.fromLLM({
maxIterations: 10,
});

await babyAGI.invoke({ objective: "Write a short weather report for SF today" });
await babyAGI.invoke({
objective: "Write a short weather report for SF today",
});
/*
*****TASK LIST*****
Expand Down
4 changes: 1 addition & 3 deletions examples/src/indexes/vector_stores/vectara.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ console.log(JSON.stringify(resultsWithScore, null, 2));
*/

const retriever = new VectaraSummaryRetriever({ vectara: store, topK: 3 });
const documents = await retriever.invoke(
"What were the women talking about?"
);
const documents = await retriever.invoke("What were the women talking about?");

console.log(JSON.stringify(documents, null, 2));
/*
Expand Down
24 changes: 12 additions & 12 deletions examples/src/models/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ export const run = async () => {

// Similar to LLMs, you can also use `generate` to generate chat completions for multiple sets of messages.
const responseC = await chat.invoke([
new SystemMessage(
"You are a helpful assistant that translates English to French."
),
new HumanMessage(
"Translate this sentence from English to French. I love programming."
),
new SystemMessage(
"You are a helpful assistant that translates English to French."
),
new HumanMessage(
"Translate this sentence from English to French. I love artificial intelligence."
),
new SystemMessage(
"You are a helpful assistant that translates English to French."
),
new HumanMessage(
"Translate this sentence from English to French. I love programming."
),
new SystemMessage(
"You are a helpful assistant that translates English to French."
),
new HumanMessage(
"Translate this sentence from English to French. I love artificial intelligence."
),
]);
console.log(responseC);
/*
Expand Down
4 changes: 1 addition & 3 deletions examples/src/retrievers/hyde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ await vectorStore.addDocuments(
].map((pageContent) => new Document({ pageContent }))
);

const results = await retriever.invoke(
"What is my favourite food?"
);
const results = await retriever.invoke("What is my favourite food?");

console.log(results);
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ await retriever.addDocuments(pamDocs, {

// This will search child documents in vector store with the help of chunk header,
// returning the unmodified parent documents
const retrievedDocs = await retriever.invoke(
"What is Pam's favorite color?"
);
const retrievedDocs = await retriever.invoke("What is Pam's favorite color?");

// Pam's favorite color is returned first!
console.log(JSON.stringify(retrievedDocs, null, 2));
Expand Down
4 changes: 1 addition & 3 deletions examples/src/retrievers/similarity_score_threshold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ const retriever = ScoreThresholdRetriever.fromVectorStore(vectorStore, {
kIncrement: 2, // How much to increase K by each time. It'll fetch N results, then N + kIncrement, then N + kIncrement * 2, etc.
});

const result = await retriever.invoke(
"What are buildings made out of?"
);
const result = await retriever.invoke("What are buildings made out of?");

console.log(result);

Expand Down
8 changes: 2 additions & 6 deletions examples/src/retrievers/time-weighted-retriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ const documents = [
// so that the correct access history metadata is populated
await retriever.addDocuments(documents);

const results1 = await retriever.invoke(
"What is my favourite food?"
);
const results1 = await retriever.invoke("What is my favourite food?");

console.log(results1);

Expand All @@ -34,9 +32,7 @@ console.log(results1);
]
*/

const results2 = await retriever.invoke(
"What is my favourite food?"
);
const results2 = await retriever.invoke("What is my favourite food?");

console.log(results2);

Expand Down

0 comments on commit 70a239f

Please sign in to comment.