Skip to content

Commit

Permalink
feat: checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
louisjoecodes committed Dec 3, 2024
1 parent 07c22f8 commit b14da04
Show file tree
Hide file tree
Showing 21 changed files with 1,295 additions and 194 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { NextResponse } from "next/server";
import { ElevenLabsClient } from "elevenlabs";

export async function GET(
request: Request,
{ params }: { params: { conversationId: string } }
) {
console.log(params);
console.log("Getting conversation", params.conversationId);
if (!process.env.XI_API_KEY) {
throw Error("XI_API_KEY is not set");
}
const elevenlabs = new ElevenLabsClient({
apiKey: process.env.XI_API_KEY,
});

try {
const conversation = await elevenlabs.conversationalAi.getConversation(
params.conversationId
);
console.log(conversation);

return NextResponse.json({ conversation });
} catch (error) {
console.error("Error getting conversation", error);
return NextResponse.json(
{ error: "Failed to get Conversation" },
{ status: 500 }
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { NextResponse } from "next/server";

export async function GET() {
const agentId = process.env.AGENT_ID;
const apiKey = process.env.XI_API_KEY;
if (!agentId) {
throw Error("AGENT_ID is not set");
}
if (!apiKey) {
throw Error("XI_API_KEY is not set");
}
try {
const response = await fetch(
`https://api.elevenlabs.io/v1/convai/conversation/get_signed_url?agent_id=${agentId}`,
{
method: "GET",
headers: {
"xi-api-key": apiKey,
},
}
);

if (!response.ok) {
throw new Error("Failed to get signed URL");
}

const data = await response.json();
return NextResponse.json({ signedUrl: data.signed_url });
} catch (error) {
console.error("Error:", error);
return NextResponse.json(
{ error: "Failed to get signed URL" },
{ status: 500 }
);
}
}
Loading

0 comments on commit b14da04

Please sign in to comment.