Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: enforce prettier #11

Merged
merged 8 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/typescript-CI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Typescript CI

on:
push:
branches: [main]
pull_request:
paths:
- "js/**"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
group: test-typescript-${{ github.head_ref }}
cancel-in-progress: true

jobs:
ci:
name: CI Typescript
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Nodejs
uses: actions/setup-node@v3
with:
node-version: 16
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 8
- name: Install Dependencies
working-directory: ./js
run: pnpm install --frozen-lockfile
- name: Formatting
working-directory: ./js
run: |
pnpm run prettier:check
1 change: 1 addition & 0 deletions js/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml
1 change: 1 addition & 0 deletions js/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2,874 changes: 1,437 additions & 1,437 deletions js/examples/openai/package-lock.json

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions js/examples/openai/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "openai-example",
"version": "0.0.0",
"private": true,
"description": "\"Example OpenAI integration with OpenInference\"",
"main": "index.js",
"scripts": {
"build": "tsc --build tsconfig.json",
"start": "node dist/index.js"
},
"author": "[email protected]",
"license": "Apache-2.0",
"dependencies": {
"@arizeai/openinference-instrumentation-openai": "^0.0.2",
"@opentelemetry/exporter-trace-otlp-http": "^0.46.0",
"@opentelemetry/exporter-trace-otlp-proto": "^0.46.0",
"@opentelemetry/resources": "^1.19.0",
"@opentelemetry/sdk-trace-node": "^1.19.0",
"openai": "^4.24.1"
}
"name": "openai-example",
"version": "0.0.0",
"private": true,
"description": "\"Example OpenAI integration with OpenInference\"",
"main": "index.js",
"scripts": {
"build": "tsc --build tsconfig.json",
"start": "node dist/index.js"
},
"author": "[email protected]",
"license": "Apache-2.0",
"dependencies": {
"@arizeai/openinference-instrumentation-openai": "^0.0.2",
"@opentelemetry/exporter-trace-otlp-http": "^0.46.0",
"@opentelemetry/exporter-trace-otlp-proto": "^0.46.0",
"@opentelemetry/resources": "^1.19.0",
"@opentelemetry/sdk-trace-node": "^1.19.0",
"openai": "^4.24.1"
}
}
30 changes: 15 additions & 15 deletions js/examples/openai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ require("./tracer");
import { OpenAI } from "openai";

const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
apiKey: process.env.OPENAI_API_KEY,
});

(async function () {
let chatCompletion = await openai.chat.completions.create({
messages: [{ role: "user", content: "Say this is a test" }],
model: "gpt-3.5-turbo",
});
chatCompletion.choices.forEach((choice) => {
console.log(choice.message);
});
chatCompletion = await openai.chat.completions.create({
messages: [{ role: "user", content: "Tell me a joke" }],
model: "gpt-3.5-turbo",
});
chatCompletion.choices.forEach((choice) => {
console.log(choice.message);
});
let chatCompletion = await openai.chat.completions.create({
messages: [{ role: "user", content: "Say this is a test" }],
model: "gpt-3.5-turbo",
});
chatCompletion.choices.forEach((choice) => {
console.log(choice.message);
});
chatCompletion = await openai.chat.completions.create({
messages: [{ role: "user", content: "Tell me a joke" }],
model: "gpt-3.5-turbo",
});
chatCompletion.choices.forEach((choice) => {
console.log(choice.message);
});
})();
24 changes: 12 additions & 12 deletions js/examples/openai/src/tracer.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { registerInstrumentations } from "@opentelemetry/instrumentation";
import { OpenAIInstrumentation } from "@arizeai/openinference-instrumentation-openai";
import {
ConsoleSpanExporter,
SimpleSpanProcessor,
BatchSpanProcessor,
ConsoleSpanExporter,
SimpleSpanProcessor,
BatchSpanProcessor,
} from "@opentelemetry/sdk-trace-base";
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
import { Resource } from "@opentelemetry/resources";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";

const provider = new NodeTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: "openai-service",
}),
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: "openai-service",
}),
});

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.addSpanProcessor(
new SimpleSpanProcessor(
new OTLPTraceExporter({
url: "http://localhost:6006/v1/traces",
})
)
new SimpleSpanProcessor(
new OTLPTraceExporter({
url: "http://localhost:6006/v1/traces",
}),
),
);
provider.register();

registerInstrumentations({
instrumentations: [new OpenAIInstrumentation({})],
instrumentations: [new OpenAIInstrumentation({})],
});
Loading