Initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { type NextRequest } from 'next/server'
|
||||
import { ChatClient } from 'dify-client-plus'
|
||||
import { v4 } from 'uuid'
|
||||
import { API_KEY, API_URL } from '@/config'
|
||||
|
||||
export const getInfo = (request: NextRequest) => {
|
||||
const username = request.cookies.get('username')?.value || 'no-user'
|
||||
const sessionId = request.cookies.get('session_id')?.value || v4()
|
||||
const user = `user_${username}:${sessionId}`
|
||||
return {
|
||||
sessionId,
|
||||
user,
|
||||
}
|
||||
}
|
||||
|
||||
export const setSession = (sessionId: string) => {
|
||||
return { 'Set-Cookie': `session_id=${sessionId}` }
|
||||
}
|
||||
|
||||
export const client = new ChatClient(API_KEY, API_URL || undefined)
|
||||
Reference in New Issue
Block a user