mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-07-13 14:43:05 +02:00
Fix misc tool call errors (#2544)
* Fix misc tool call errors * Fix middleware
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
import itertools
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from collections.abc import Iterator
|
from collections.abc import Iterator
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@ -554,8 +555,7 @@ class Answer:
|
|||||||
|
|
||||||
def _stream() -> Iterator[str]:
|
def _stream() -> Iterator[str]:
|
||||||
nonlocal stream_stop_info
|
nonlocal stream_stop_info
|
||||||
yield cast(str, message)
|
for item in itertools.chain([message], stream):
|
||||||
for item in stream:
|
|
||||||
if isinstance(item, StreamStopInfo):
|
if isinstance(item, StreamStopInfo):
|
||||||
stream_stop_info = item
|
stream_stop_info = item
|
||||||
return
|
return
|
||||||
|
@ -2,24 +2,29 @@ import { NextResponse } from "next/server";
|
|||||||
import type { NextRequest } from "next/server";
|
import type { NextRequest } from "next/server";
|
||||||
import { SERVER_SIDE_ONLY__PAID_ENTERPRISE_FEATURES_ENABLED } from "./lib/constants";
|
import { SERVER_SIDE_ONLY__PAID_ENTERPRISE_FEATURES_ENABLED } from "./lib/constants";
|
||||||
|
|
||||||
|
// NOTE: have to have the "/:path*" here since NextJS doesn't allow any real JS to
|
||||||
|
// be run before the config is defined e.g. if we try and do a .map it will complain
|
||||||
const eePaths = [
|
const eePaths = [
|
||||||
"/admin/groups",
|
"/admin/groups/:path*",
|
||||||
"/admin/api-key",
|
"/admin/api-key/:path*",
|
||||||
"/admin/performance/usage",
|
"/admin/performance/usage/:path*",
|
||||||
"/admin/performance/query-history",
|
"/admin/performance/query-history/:path*",
|
||||||
"/admin/whitelabeling",
|
"/admin/whitelabeling/:path*",
|
||||||
"/admin/performance/custom-analytics",
|
"/admin/performance/custom-analytics/:path*",
|
||||||
"/admin/standard-answer",
|
"/admin/standard-answer/:path*",
|
||||||
];
|
];
|
||||||
|
|
||||||
const eePathsForMatcher = eePaths.map((path) => `${path}/:path*`);
|
// removes the "/:path*" from the end
|
||||||
|
const strippedEEPaths = eePaths.map((path) =>
|
||||||
|
path.replace(/(.*):\path\*$/, "$1").replace(/\/$/, "")
|
||||||
|
);
|
||||||
|
|
||||||
export async function middleware(request: NextRequest) {
|
export async function middleware(request: NextRequest) {
|
||||||
if (SERVER_SIDE_ONLY__PAID_ENTERPRISE_FEATURES_ENABLED) {
|
if (SERVER_SIDE_ONLY__PAID_ENTERPRISE_FEATURES_ENABLED) {
|
||||||
const pathname = request.nextUrl.pathname;
|
const pathname = request.nextUrl.pathname;
|
||||||
|
|
||||||
// Check if the current path is in the eePaths list
|
// Check if the current path is in the eePaths list
|
||||||
if (eePaths.some((path) => pathname.startsWith(path))) {
|
if (strippedEEPaths.some((path) => pathname.startsWith(path))) {
|
||||||
// Add '/ee' to the beginning of the pathname
|
// Add '/ee' to the beginning of the pathname
|
||||||
const newPathname = `/ee${pathname}`;
|
const newPathname = `/ee${pathname}`;
|
||||||
|
|
||||||
@ -37,5 +42,5 @@ export async function middleware(request: NextRequest) {
|
|||||||
|
|
||||||
// Specify the paths that the middleware should run for
|
// Specify the paths that the middleware should run for
|
||||||
export const config = {
|
export const config = {
|
||||||
matcher: eePathsForMatcher,
|
matcher: eePaths,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user