Skip to content

Commit

Permalink
Add langfuse for tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
SuveenE committed Jan 10, 2025
1 parent 4075983 commit 2ecdd63
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
OPENAI_API_KEY=
ENVIRONMENT=development
LANGFUSE_SECRET_KEY="sk-lf-..."
LANGFUSE_PUBLIC_KEY="pk-lf-..."
LANGFUSE_BASEURL="https://us.cloud.langfuse.com"
9 changes: 6 additions & 3 deletions app/api/gpt/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import { getSystemPrompt, generatePrompt } from "@/utils/prompts";
import { ClueResponseSchema, GuessResponseSchema } from "@/types/requests";
import { zodResponseFormat } from "openai/helpers/zod";
import { delay } from "@/utils/gameUtils";
import { observeOpenAI } from "langfuse";

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

const MAX_RETRIES = 2;

Expand Down
34 changes: 34 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"fs": "^0.0.1-security",
"langfuse": "^3.32.0",
"lucide-react": "^0.469.0",
"next": "14.2.16",
"openai": "^4.77.0",
Expand Down

0 comments on commit 2ecdd63

Please sign in to comment.