feat: user field added to valves

This commit is contained in:
Timothy J. Baek 2024-05-27 19:15:00 -07:00
parent 91f58c52e5
commit 72749845dc
3 changed files with 8 additions and 4 deletions

View File

@ -170,7 +170,7 @@ async def valve(form_data: ValveForm):
) )
pipeline = PIPELINE_MODULES[form_data.model] pipeline = PIPELINE_MODULES[form_data.model]
return await pipeline.control_valve(form_data.body) return await pipeline.control_valve(form_data.body, form_data.user)
@app.post("/chat/completions") @app.post("/chat/completions")

View File

@ -1,4 +1,4 @@
from typing import List, Union, Generator, Iterator from typing import List, Optional
from schemas import OpenAIChatMessage from schemas import OpenAIChatMessage
@ -31,7 +31,10 @@ class Pipeline:
print(f"on_shutdown:{__name__}") print(f"on_shutdown:{__name__}")
pass pass
async def control_valve(self, body: dict) -> dict: async def control_valve(self, body: dict, user: Optional[dict] = None) -> dict:
print(f"get_response:{__name__}") print(f"get_response:{__name__}")
print(body) print(body)
print(user)
return body return body

View File

@ -1,4 +1,4 @@
from typing import List from typing import List, Optional
from pydantic import BaseModel, ConfigDict from pydantic import BaseModel, ConfigDict
@ -20,4 +20,5 @@ class OpenAIChatCompletionForm(BaseModel):
class ValveForm(BaseModel): class ValveForm(BaseModel):
model: str model: str
body: dict body: dict
user: Optional[dict] = None
model_config = ConfigDict(extra="allow") model_config = ConfigDict(extra="allow")