Skip to content
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

modify request body using pydantic BaseModel #633

Open
restuprajna opened this issue May 6, 2024 · 0 comments
Open

modify request body using pydantic BaseModel #633

restuprajna opened this issue May 6, 2024 · 0 comments

Comments

@restuprajna
Copy link

I want to modify request body to send to the model, is there a way to use pydantic to modify input_type

for example this is the default req body:

{
  "inputs": [
    "string"
  ],
  "config": {},
  "kwargs": {}
}

i want to change like this:

{
  "inputs": [
    "string"
  ],
  "config": {},
  "kwargs": {},
  "metadata":["string"]
}

because i want to get the value inside the metadata for filtering rag document.

here are my chain

chain = (
    {"context": retriever | RunnablePassthrough(), "task": RunnablePassthrough()}
    | pipeline_prompt 
    | llm 
    | parser
)

class InputPrompt(BaseModel):
    __root__: str


chain = chain.with_types(input_type=InputPrompt)

and I'm using APIHandler to make batch and invoke method:

async def batch_api(api_chain, path: str, request: Request) -> Response:
    """
    Handle a request for the specified API.
    """
    api_handler = APIHandler(api_chain, path=path)
    return await api_handler.batch(request, server_config=langfuse_config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant