Skip to content

Commit

Permalink
ci: enforce prettier (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeldking authored Dec 28, 2023
1 parent d650052 commit 9742688
Show file tree
Hide file tree
Showing 28 changed files with 5,652 additions and 4,000 deletions.
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": "mikyo@arize.com",
"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": "mikyo@arize.com",
"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

0 comments on commit 9742688

Please sign in to comment.