-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Problem
The instrumentation example doesn't show TypeScript usage, which is important since Hive is built with TypeScript and most production applications use it.
Current Example (JavaScript):
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello!" }],
});No type information for:
- Instrument configuration options
- OpenAI response structure
- Error handling types
Proposed Solution
Add TypeScript example alongside JavaScript:
New file: examples/typescript-quickstart.ts
import { instrument, InstrumentConfig } from "aden";
import OpenAI from "openai";
import type { ChatCompletionMessageParam } from "openai/resources/chat";
// Type-safe instrumentation
const config: InstrumentConfig = {
sdks: { OpenAI },
// Show other available options
projectId: process.env.ADEN_PROJECT_ID,
apiKey: process.env.ADEN_API_KEY,
};
await instrument(config);
const openai = new OpenAI();
// Type-safe messages
const messages: ChatCompletionMessageParam[] = [
{ role: "user", content: "Hello!" }
];
try {
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages,
});
console.log(response.choices[0]?.message.content);
} catch (error) {
if (error instanceof OpenAI.APIError) {
console.error(`OpenAI Error: ${error.status} - ${error.message}`);
}
throw error;
}Benefits
- Better IDE autocomplete
- Catch errors at compile time
- Professional example for production use
- Shows Aden's TypeScript support
Files to Create/Update
- Create
examples/typescript-quickstart.ts - Update
README.mdwith TypeScript tab - Add to
examples/README.md
Interested in submitting this enhancement?
### **Labels:** `enhancement`, `documentation`, `typescript`
---
## **ISSUE #3: Missing Error Handling**
### **Issue Title:**
Quick start example lacks error handling for API failures
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels