This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<parent> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-parent</artifactId> | |
<version>3.2.5</version> <!-- Use a recent Spring Boot 3 version --> | |
<relativePath/> <!-- lookup parent from repository --> | |
</parent> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.stereotype.Component; | |
import org.springframework.web.reactive.function.server.ServerRequest; | |
import org.springframework.web.reactive.function.server.ServerResponse; | |
import reactor.core.publisher.Mono; | |
@Component | |
public class ProxyHandler { | |
private final RoutingService routingService; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, Index } from 'typeorm'; | |
import { StoredMessage } from '@langchain/core/messages'; | |
@Entity('chat_messages_lc') // Using '_lc' suffix to denote Langchain specific table | |
export class ChatMessageStoredEntity { | |
@PrimaryGeneratedColumn('uuid') | |
id!: string; | |
@Index() // Index sessionId for faster querying | |
@Column() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Connecting to Azure SQL Database from a Next.js application using DefaultAzureCredential and an ORM in TypeScript allows for passwordless, secure, and environment-aware authentication. This approach is highly recommended as DefaultAzureCredential automatically handles various authentication scenarios, such as using your Azure CLI or Visual Studio Code credentials during local development, or a Managed Identity when deployed to Azure services. | |
This guide will primarily focus on TypeORM, which offers more straightforward integration for this authentication method with Azure SQL. We will also briefly discuss considerations for Prisma. | |
Current Date: May 19, 2025 | |
Key Technologies: | |
Next.js: React framework for server-rendered applications. | |
TypeScript: For type safety. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { CSSProperties, forwardRef, ReactNode, useEffect, useMemo } from 'react'; // Added useMemo | |
import { motion, useAnimation } from 'framer-motion'; | |
import { Sparkles as ButtonIcon } from 'lucide-react'; | |
// --- Define Types and Props --- | |
// Define possible button sizes, including x-small | |
type ButtonSize = 'x-small' | 'small' | 'normal' | 'large'; // Added 'x-small' | |
// Props for the underlying custom button (remains the same) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const escapeCurlyBraces = (text) => { | |
// This regex matches any number of consecutive curly braces | |
return text.replace( | |
/({{+)((?:[^{}]|{{|}})*)(}})+/g, | |
(match, openBraces, content, closeBraces) => { | |
const escapedOpen = openBraces.replace(/{{/g, "{$"); | |
const escapedClose = closeBraces.replace(/}}/g, "$}"); | |
return `${escapedOpen}${content}${escapedClose}`; | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from "react" | |
export const useBaseStorageState = ( | |
storage, | |
storageKey, | |
defaultValue, | |
live = false | |
) => { | |
// Get value from storage, if not use default value | |
const [state, setState] = useState(() => { |