mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-03-26 17:51:54 +01:00
Fix misc tool call errors (#2544)
* Fix misc tool call errors * Fix middleware
This commit is contained in:
parent
316b6b99ea
commit
77650c9ee3
@ -1,3 +1,4 @@
|
||||
import itertools
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Iterator
|
||||
from typing import Any
|
||||
@ -554,8 +555,7 @@ class Answer:
|
||||
|
||||
def _stream() -> Iterator[str]:
|
||||
nonlocal stream_stop_info
|
||||
yield cast(str, message)
|
||||
for item in stream:
|
||||
for item in itertools.chain([message], stream):
|
||||
if isinstance(item, StreamStopInfo):
|
||||
stream_stop_info = item
|
||||
return
|
||||
|
@ -2,24 +2,29 @@ import { NextResponse } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
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 = [
|
||||
"/admin/groups",
|
||||
"/admin/api-key",
|
||||
"/admin/performance/usage",
|
||||
"/admin/performance/query-history",
|
||||
"/admin/whitelabeling",
|
||||
"/admin/performance/custom-analytics",
|
||||
"/admin/standard-answer",
|
||||
"/admin/groups/:path*",
|
||||
"/admin/api-key/:path*",
|
||||
"/admin/performance/usage/:path*",
|
||||
"/admin/performance/query-history/:path*",
|
||||
"/admin/whitelabeling/:path*",
|
||||
"/admin/performance/custom-analytics/:path*",
|
||||
"/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) {
|
||||
if (SERVER_SIDE_ONLY__PAID_ENTERPRISE_FEATURES_ENABLED) {
|
||||
const pathname = request.nextUrl.pathname;
|
||||
|
||||
// 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
|
||||
const newPathname = `/ee${pathname}`;
|
||||
|
||||
@ -37,5 +42,5 @@ export async function middleware(request: NextRequest) {
|
||||
|
||||
// Specify the paths that the middleware should run for
|
||||
export const config = {
|
||||
matcher: eePathsForMatcher,
|
||||
matcher: eePaths,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user