Louai_team_performance_review.ts24 matches
12import {
13AIPerformanceAnalysis,
14createOpenAIClient,
15LouOpenAIClient,
16validatePerformanceData,
17validateWaiverData,
18WaiverRecommendation,
19} from "./ai_performance_openai_client.ts";
20import {
21createPromptConfig,
39maxWaiverCandidates: number; // Maximum waiver candidates to analyze (default: 15)
4041// OpenAI configuration
42openai: {
43model: "gpt-4-turbo-preview" | "gpt-4o" | "gpt-3.5-turbo";
44maxTokens: number;
159export class AITeamPerformanceReviewer {
160private performanceAnalyzer: LouPerformanceAnalyzer;
161private openaiClient: LouOpenAIClient;
162private tokenStorage: LouTokenStorage;
163private config: AITeamReviewConfig;
169minConfidenceThreshold: 70,
170maxWaiverCandidates: 15,
171openai: {
172model: "gpt-4-turbo-preview",
173maxTokens: 4000,
190// Initialize components
191this.performanceAnalyzer = new LouPerformanceAnalyzer();
192this.openaiClient = createOpenAIClient({
193model: this.config.openai.model,
194maxTokens: this.config.openai.maxTokens,
195temperature: this.config.openai.temperature,
196});
197this.tokenStorage = new LouTokenStorage();
198199console.log(`🤖 AI Team Performance Reviewer initialized with model: ${this.config.openai.model}`);
200}
201420authentication: boolean;
421yahooAPI: boolean;
422openAI: boolean;
423performanceAnalyzer: boolean;
424};
430authentication: false,
431yahooAPI: false,
432openAI: false,
433performanceAnalyzer: false,
434};
445}
446447// Test 2: OpenAI API
448try {
449const openAITest = await this.openaiClient.testConnection();
450results.openAI = openAITest.success;
451if (!openAITest.success) {
452errors.push(`OpenAI test failed: ${openAITest.error}`);
453}
454console.log(openAITest.success ? "✅ OpenAI test passed" : "❌ OpenAI test failed");
455} catch (error) {
456errors.push(`OpenAI test failed: ${error}`);
457console.log("❌ OpenAI test failed");
458}
459679680// Execute AI analysis
681const analysis = await this.openaiClient.analyzeTeamPerformance({
682teamStats: data.teamStats,
683playerStats: data.playerStats,
731732// Generate AI recommendations
733const recommendations = await this.openaiClient.getPickupRecommendations(
734underperformers,
735data.waiverPlayers,
openai-clientopenai-client.mdc7 matches
1---
2description: You can use openai-client when integrating vals to an LLM
3globs:
4alwaysApply: false
5---
6TypeScript interface for interacting with OpenAI's chat models, with optional global rate limiting, and uses Val Town's SQLite for persistent rate limit tracking.
7Key Components
8Message Type: Defines the structure for chat messages (role and content).
9ChatOpenAI(model: string): Factory function returning an object with an invoke(messages) method. This method sends an array of messages to the specified OpenAI chat model and returns the assistant's response.
10GlobalRateLimitedChatOpenAI(model: string, requestsPerSecond: number): Decorator for ChatOpenAI that enforces a global rate limit (requests per second) using a persistent SQLite table.
11GlobalRateLimiter: Class that implements the rate limiting logic. It checks the number of requests in the current time window and throws an error if the limit is exceeded. It uses a table (global_rate_limit_1) in Val Town's SQLite.
12ensureGlobalRateLimitTableExists: Ensures the rate limit tracking table exists in the database at startup.
13Usage
14Use ChatOpenAI(model) for direct, unlimited access to OpenAI chat completions.
15Use GlobalRateLimitedChatOpenAI(model, requestsPerSecond) to enforce a global rate limit on chat completions, suitable for shared or public-facing endpoints.
16Val Town/Platform Notes
17Uses Val Town’s standard SQLite API for persistent storage.
18Designed for server-side use (no browser-specific code).
19No secrets are hardcoded; OpenAI API keys are managed by the OpenAI SDK/environment.
openai-client.cursorrules4 matches
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
9596### OpenAI
9798```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102messages: [
103{ role: "user", content: "Say hello in a creative way" },
openai-clientknowledge.md4 matches
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
9596### OpenAI
9798```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102messages: [
103{ role: "user", content: "Say hello in a creative way" },
securityknowledge.md4 matches
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
9596### OpenAI
9798```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102messages: [
103{ role: "user", content: "Say hello in a creative way" },
security.cursorrules4 matches
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
9596### OpenAI
9798```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102messages: [
103{ role: "user", content: "Say hello in a creative way" },
hm-invoicesv1VAL-TOWN-RULES.md4 matches
66Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
6768### OpenAI
6970```ts
71import { OpenAI } from "https://esm.town/v/std/openai";
72const openai = new OpenAI();
73const completion = await openai.chat.completions.create({
74messages: [
75{ role: "user", content: "Say hello in a creative way" },
api_ianmenethil_comopenaiClient.ts5 matches
1// Future implementation of OpenAI client for API calls
2import { OpenAI } from "openai";
34const openai = new OpenAI({
5apiKey: Deno.env.get("OPENAI_API_KEY"),
6});
78export default openai;
9
api_ianmenethil_comservicesConfig.ts4 matches
13ENABLED: !!Deno.env.get("FIRECRAWL_API_KEY"),
14},
15OPENAI: {
16API_KEY: Deno.env.get("OPENAI_API_KEY"),
17BASE_URL: "https://api.openai.com/v1",
18TIMEOUT: 30000,
19ENABLED: !!Deno.env.get("OPENAI_API_KEY"),
20},
21RESEND: {
api_ianmenethil_comappTypes.ts2 matches
209}
210211export interface OpenAIServiceConfig {
212API_KEY?: string;
213BASE_URL: string;
226TAVILY: TavilyServiceConfig;
227FIRECRAWL: FirecrawlServiceConfig;
228OPENAI: OpenAIServiceConfig;
229RESEND: ResendServiceConfig;
230}