Commit 6ccb5e8f authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

feat: user valves support

parent d362fd02
...@@ -278,6 +278,9 @@ async def get_function_call_response( ...@@ -278,6 +278,9 @@ async def get_function_call_response(
"email": user.email, "email": user.email,
"name": user.name, "name": user.name,
"role": user.role, "role": user.role,
"valves": Tools.get_user_valves_by_id_and_user_id(
tool_id, user.id
),
}, },
} }
...@@ -401,6 +404,9 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware): ...@@ -401,6 +404,9 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
"email": user.email, "email": user.email,
"name": user.name, "name": user.name,
"role": user.role, "role": user.role,
"valves": Functions.get_user_valves_by_id_and_user_id(
filter_id, user.id
),
}, },
} }
...@@ -871,10 +877,14 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u ...@@ -871,10 +877,14 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
"email": user.email, "email": user.email,
"name": user.name, "name": user.name,
"role": user.role, "role": user.role,
"valves": Functions.get_user_valves_by_id_and_user_id(
pipe_id, user.id
),
}, },
} }
if form_data["stream"]: if form_data["stream"]:
async def stream_content(): async def stream_content():
if inspect.iscoroutinefunction(pipe): if inspect.iscoroutinefunction(pipe):
res = await pipe(**param) res = await pipe(**param)
...@@ -1010,7 +1020,12 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)): ...@@ -1010,7 +1020,12 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)):
f"{url}/{filter['id']}/filter/outlet", f"{url}/{filter['id']}/filter/outlet",
headers=headers, headers=headers,
json={ json={
"user": {"id": user.id, "name": user.name, "role": user.role}, "user": {
"id": user.id,
"name": user.name,
"email": user.email,
"role": user.role,
},
"body": data, "body": data,
}, },
) )
...@@ -1064,6 +1079,9 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)): ...@@ -1064,6 +1079,9 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)):
"email": user.email, "email": user.email,
"name": user.name, "name": user.name,
"role": user.role, "role": user.role,
"valves": Functions.get_user_valves_by_id_and_user_id(
filter_id, user.id
),
}, },
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment