Skip to content

Commit

Permalink
Add pre commit (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole White authored Oct 27, 2023
1 parent ed3fa01 commit 51b97b8
Show file tree
Hide file tree
Showing 31 changed files with 121 additions and 70 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ on:
# servers.
#
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: "17 12 * * *"
- cron: '17 12 * * *'

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]

test-readmes-up-to-date:
runs-on: ubuntu-latest

Expand Down
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml

- repo: https://github.com/psf/black
rev: '23.10.1'
hooks:
- id: black
language_version: python3

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier
4 changes: 4 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
trailingComma: all
tabWidth: 2
semi: true
singleQuote: true
3 changes: 2 additions & 1 deletion JavaScript/chatbot-nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ This is a Next.js app that uses openai and Autoblocks to power and monitor a cha
View the deployed application at https://chatbot-example.autoblocks.ai

<!-- getting started start -->

## Getting started

- Sign up for an Autoblocks account at https://app.autoblocks.ai
- Grab your Autoblocks ingestion key from https://app.autoblocks.ai/settings/api-keys
- Grab your OpenAI API key from https://platform.openai.com/account/api-keys
- Create a file named `.env` in this folder and include the following environment variables:

`.env`
```
OPENAI_API_KEY=<your-api-key>
AUTOBLOCKS_INGESTION_KEY=<your-ingestion-key>
```

<!-- getting started end -->

## Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion JavaScript/chatbot-nextjs/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module.exports = {
tailwindcss: {},
autoprefixer: {},
},
}
};
2 changes: 1 addition & 1 deletion JavaScript/chatbot-nextjs/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion JavaScript/chatbot-nextjs/public/thirteen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion JavaScript/chatbot-nextjs/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions JavaScript/chatbot-nextjs/src/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Html, Head, Main, NextScript } from 'next/document'
import { Html, Head, Main, NextScript } from 'next/document';

export default function Document() {
return (
Expand All @@ -9,5 +9,5 @@ export default function Document() {
<NextScript />
</body>
</Html>
)
);
}
2 changes: 1 addition & 1 deletion JavaScript/chatbot-nextjs/src/pages/api/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Sometimes you do not know the answer.

export default async function handler(
req: NextApiRequest,
res: NextApiResponse
res: NextApiResponse,
) {
const { userInput, pastMessages, traceId, autoblocksIngestionKey } =
JSON.parse(req.body);
Expand Down
4 changes: 2 additions & 2 deletions JavaScript/chatbot-nextjs/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function Message({
<div
className={classNames(
'order-2',
showAvatar ? 'visible' : 'invisible'
showAvatar ? 'visible' : 'invisible',
)}
>
<Avatar firstName={'Adam'} lastName={'Nolte'} />
Expand All @@ -273,7 +273,7 @@ function Message({
<div
className={classNames(
'text-2xl order-1',
showAvatar ? 'visible' : 'invisible'
showAvatar ? 'visible' : 'invisible',
)}
>
🤖
Expand Down
3 changes: 2 additions & 1 deletion JavaScript/langchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@
<!-- banner end -->

<!-- getting started start -->

## Getting started

- Sign up for an Autoblocks account at https://app.autoblocks.ai
- Grab your Autoblocks ingestion key from https://app.autoblocks.ai/settings/api-keys
- Grab your OpenAI API key from https://platform.openai.com/account/api-keys
- Create a file named `.env` in this folder and include the following environment variables:

`.env`
```
OPENAI_API_KEY=<your-api-key>
AUTOBLOCKS_INGESTION_KEY=<your-ingestion-key>
```

<!-- getting started end -->

## Install dependencies
Expand Down
16 changes: 8 additions & 8 deletions JavaScript/langchain/src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AutoblocksCallbackHandler } from '@autoblocks/client/langchain';
import { OpenAI } from "langchain/llms/openai";
import { DynamicTool } from "langchain/tools";
import { Calculator } from "langchain/tools/calculator";
import { initializeAgentExecutorWithOptions } from "langchain/agents";
import { OpenAI } from 'langchain/llms/openai';
import { DynamicTool } from 'langchain/tools';
import { Calculator } from 'langchain/tools/calculator';
import { initializeAgentExecutorWithOptions } from 'langchain/agents';

const main = async () => {
const model = new OpenAI({ temperature: 0 });
Expand All @@ -23,12 +23,12 @@ const main = async () => {
const handler = new AutoblocksCallbackHandler();
const output = await executor.run(
"What is today's date? What is that date divided by 2?",
{ callbacks: [handler]
});
{ callbacks: [handler] },
);

console.log(`Output: ${output}`);
console.log('\n');
console.log('View your trace: https://app.autoblocks.ai/explore')
}
console.log('View your trace: https://app.autoblocks.ai/explore');
};

main();
3 changes: 2 additions & 1 deletion JavaScript/novel-ai-text-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@
Example Next.js application using [Novel](https://github.com/steven-tey/novel). Based on [novella](https://github.com/steven-tey/novella).

<!-- getting started start -->

## Getting started

- Sign up for an Autoblocks account at https://app.autoblocks.ai
- Grab your Autoblocks ingestion key from https://app.autoblocks.ai/settings/api-keys
- Grab your OpenAI API key from https://platform.openai.com/account/api-keys
- Create a file named `.env` in this folder and include the following environment variables:

`.env`
```
OPENAI_API_KEY=<your-api-key>
AUTOBLOCKS_INGESTION_KEY=<your-ingestion-key>
```

<!-- getting started end -->

## Install Dependencies
Expand Down
4 changes: 2 additions & 2 deletions JavaScript/novel-ai-text-editor/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}
const nextConfig = {};

module.exports = nextConfig
module.exports = nextConfig;
2 changes: 1 addition & 1 deletion JavaScript/novel-ai-text-editor/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module.exports = {
tailwindcss: {},
autoprefixer: {},
},
}
};
2 changes: 1 addition & 1 deletion JavaScript/novel-ai-text-editor/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion JavaScript/novel-ai-text-editor/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function POST(req: Request): Promise<Response> {
'Missing OPENAI_API_KEY – make sure to add it to your .env file.',
{
status: 400,
}
},
);
}
// Start the timer for duration tracking till the end of the stream
Expand Down
6 changes: 3 additions & 3 deletions JavaScript/novel-ai-text-editor/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Config } from 'tailwindcss'
import type { Config } from 'tailwindcss';

const config: Config = {
content: [
Expand All @@ -16,5 +16,5 @@ const config: Config = {
},
},
plugins: [],
}
export default config
};
export default config;
3 changes: 2 additions & 1 deletion JavaScript/openai-automated/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@
<!-- banner end -->

<!-- getting started start -->

## Getting started

- Sign up for an Autoblocks account at https://app.autoblocks.ai
- Grab your Autoblocks ingestion key from https://app.autoblocks.ai/settings/api-keys
- Grab your OpenAI API key from https://platform.openai.com/account/api-keys
- Create a file named `.env` in this folder and include the following environment variables:

`.env`
```
OPENAI_API_KEY=<your-api-key>
AUTOBLOCKS_INGESTION_KEY=<your-ingestion-key>
```

<!-- getting started end -->

## Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion JavaScript/openai-automated/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function main() {
await openai.chat.completions.create(openAIRequest);
console.log('Finished calling OpenAI');

console.log('View the trace at https://app.autoblocks.ai/explore')
console.log('View the trace at https://app.autoblocks.ai/explore');
}

main();
3 changes: 2 additions & 1 deletion JavaScript/openai-manual/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@
<!-- banner end -->

<!-- getting started start -->

## Getting started

- Sign up for an Autoblocks account at https://app.autoblocks.ai
- Grab your Autoblocks ingestion key from https://app.autoblocks.ai/settings/api-keys
- Grab your OpenAI API key from https://platform.openai.com/account/api-keys
- Create a file named `.env` in this folder and include the following environment variables:

`.env`
```
OPENAI_API_KEY=<your-api-key>
AUTOBLOCKS_INGESTION_KEY=<your-ingestion-key>
```

<!-- getting started end -->

## Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion JavaScript/openai-manual/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function run() {
}

console.log(
`Finished running example. View the trace at https://app.autoblocks.ai/explore/trace/${traceId}`
`Finished running example. View the trace at https://app.autoblocks.ai/explore/trace/${traceId}`,
);
}

Expand Down
3 changes: 2 additions & 1 deletion Python/langchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@
<!-- banner end -->

<!-- getting started start -->

## Getting started

- Sign up for an Autoblocks account at https://app.autoblocks.ai
- Grab your Autoblocks ingestion key from https://app.autoblocks.ai/settings/api-keys
- Grab your OpenAI API key from https://platform.openai.com/account/api-keys
- Create a file named `.env` in this folder and include the following environment variables:

`.env`
```
OPENAI_API_KEY=<your-api-key>
AUTOBLOCKS_INGESTION_KEY=<your-ingestion-key>
```

<!-- getting started end -->

## Install dependencies
Expand Down
3 changes: 2 additions & 1 deletion Python/openai-automated/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@
<!-- banner end -->

<!-- getting started start -->

## Getting started

- Sign up for an Autoblocks account at https://app.autoblocks.ai
- Grab your Autoblocks ingestion key from https://app.autoblocks.ai/settings/api-keys
- Grab your OpenAI API key from https://platform.openai.com/account/api-keys
- Create a file named `.env` in this folder and include the following environment variables:

`.env`
```
OPENAI_API_KEY=<your-api-key>
AUTOBLOCKS_INGESTION_KEY=<your-ingestion-key>
```

<!-- getting started end -->

## Install dependencies
Expand Down
7 changes: 2 additions & 5 deletions Python/openai-automated/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ def main():
messages=[
{
"role": "system",
"content": "You are a helpful assistant. You answer questions about a software product named Acme."
"content": "You are a helpful assistant. You answer questions about a software product named Acme.",
},
{
"role": "user",
"content": "How do I sign up?"
}
{"role": "user", "content": "How do I sign up?"},
],
model="gpt-3.5-turbo",
temperature=0.7,
Expand Down
Loading

1 comment on commit 51b97b8

@vercel
Copy link

@vercel vercel bot commented on 51b97b8 Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.