- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3
Feat/rag is dumb so gpt4omini #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
792899f
              4ff2dc9
              3ecb955
              4985149
              f89cbf8
              843a635
              2d40f58
              b05a3e7
              f7d4c21
              14c9a52
              6421ea5
              a536c98
              09ca46e
              a9f871b
              aa810b5
              b293ee1
              8860b38
              c1ea285
              8a7d4f9
              ed999eb
              0b41738
              f7fd67f
              6dbef56
              4436c31
              5a02bd4
              7dfd459
              6d9873c
              6301c3f
              d60e03c
              1bc0551
              8f9e112
              fc41f02
              ebeeeed
              5251b4c
              d020d49
              fdb2f20
              753c451
              ba4b635
              0581044
              351ba35
              90ea40c
              b886d1b
              80af25a
              dba549c
              7ad7c4d
              abb6ca2
              64d1573
              c61246d
              11fe524
              332e68d
              35ee1e6
              518fb0b
              78da922
              2246906
              ec4fda7
              a28b25d
              c9922ff
              00f5083
              819e45c
              8b30d60
              7193788
              9cf4c14
              5c0bf92
              fcbdbae
              47b4224
              9450c04
              99d4562
              91482be
              c316d67
              c179242
              adc9966
              d8a3d99
              6a882ee
              403804c
              18bb473
              16a4cf1
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| import { | ||
| UIMessage, | ||
| type UIMessage, | ||
| appendResponseMessages, | ||
| createDataStreamResponse, | ||
| experimental_createMCPClient as createMCPClient, | ||
| smoothStream, | ||
| streamText, | ||
| } from 'ai'; | ||
|  | @@ -25,6 +26,9 @@ import { requestSuggestions } from '@/lib/ai/tools/request-suggestions'; | |
| import { getWeather } from '@/lib/ai/tools/get-weather'; | ||
| import { isProductionEnvironment } from '@/lib/constants'; | ||
| import { myProvider } from '@/lib/ai/providers'; | ||
| import * as meetingBaas from '@/server/meetingbaas'; | ||
| import { activeTools as mcpActiveTools } from '@/lib/ai/tools/mcp'; | ||
| import { getInformation } from '@/lib/ai/tools/get-information'; | ||
|  | ||
| export const maxDuration = 60; | ||
|  | ||
|  | @@ -41,6 +45,7 @@ export async function POST(request: Request) { | |
| } = await request.json(); | ||
|  | ||
| const session = await auth(); | ||
| const baasSession = await meetingBaas.auth(); | ||
|  | ||
| if (!session || !session.user || !session.user.id) { | ||
| return new Response('Unauthorized', { status: 401 }); | ||
|  | @@ -79,11 +84,28 @@ export async function POST(request: Request) { | |
| ], | ||
| }); | ||
|  | ||
| const client = await createMCPClient({ | ||
| transport: { | ||
| type: 'sse', | ||
| url: 'https://mcp.meetingbaas.com/sse', | ||
| headers: { | ||
| 'x-meeting-baas-api-key': baasSession?.apiKey ?? 'invalid-api-key', | ||
| }, | ||
| }, | ||
| onUncaughtError: (error) => { | ||
| console.error('MCP Client error:', error); | ||
| }, | ||
| }); | ||
| const mcpTools = await client.tools(); | ||
|  | ||
| return createDataStreamResponse({ | ||
| execute: (dataStream) => { | ||
| execute: async (dataStream) => { | ||
| const result = streamText({ | ||
| model: myProvider.languageModel(selectedChatModel), | ||
| system: systemPrompt({ selectedChatModel }), | ||
| system: systemPrompt({ | ||
| selectedChatModel, | ||
| baasApiKey: baasSession?.apiKey, | ||
| }), | ||
| messages, | ||
| maxSteps: 5, | ||
| experimental_activeTools: | ||
|  | @@ -94,6 +116,8 @@ export async function POST(request: Request) { | |
| 'createDocument', | ||
| 'updateDocument', | ||
| 'requestSuggestions', | ||
| 'getInformation', | ||
| ...(mcpActiveTools as any[]), | ||
| ], | ||
| experimental_transform: smoothStream({ chunking: 'word' }), | ||
| experimental_generateMessageId: generateUUID, | ||
|  | @@ -105,6 +129,8 @@ export async function POST(request: Request) { | |
| session, | ||
| dataStream, | ||
| }), | ||
| getInformation, | ||
| ...mcpTools | ||
| 
      Comment on lines
    
      +132
     to 
      +133
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify tool implementation consistency The getInformation tool is directly imported while mcpTools are spread. Ensure both approaches are used consistently and the tools have matching interfaces. 🏁 Script executed: #!/bin/bash
# Check mcpActiveTools implementation
cat lib/ai/tools/mcp.tsLength of output: 346 Action Required: Align Tool Interfaces The  
 | ||
| }, | ||
| onFinish: async ({ response }) => { | ||
| if (session.user?.id) { | ||
|  | @@ -141,6 +167,11 @@ export async function POST(request: Request) { | |
| console.error('Failed to save chat'); | ||
| } | ||
| } | ||
|  | ||
| client.close(); | ||
| }, | ||
| onError: async () => { | ||
| client.close(); | ||
| }, | ||
| experimental_telemetry: { | ||
| isEnabled: isProductionEnvironment, | ||
|  | @@ -154,7 +185,9 @@ export async function POST(request: Request) { | |
| sendReasoning: true, | ||
| }); | ||
| }, | ||
| onError: () => { | ||
| onError: (error) => { | ||
| console.error('Error in data stream:', error); | ||
| client.close(); | ||
| return 'Oops, an error occured!'; | ||
| }, | ||
| }); | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,6 +1,4 @@ | ||
| 'use client'; | ||
|  | ||
| import type { Message } from 'ai'; | ||
| import cx from 'classnames'; | ||
| import { | ||
| AnimatePresence, | ||
|  | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Ensure MeetingBaas authentication is properly handled
The authentication with MeetingBaas is correctly implemented, but there's no error handling if the authentication fails.
Consider adding error handling for the MeetingBaas authentication:
📝 Committable suggestion