Skip to content

Commit

Permalink
prefer_markdown option in chat (#2098)
Browse files Browse the repository at this point in the history
* prefer_markdown option in chat

* fix

* fix

---------

Co-authored-by: Ferran Llamas <ferran@nuclia.com>
  • Loading branch information
vangheem and lferran authored May 9, 2024
1 parent 92ea844 commit e0115a9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions nucliadb/nucliadb/search/search/chat/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ async def chat(
generative_model=chat_request.generative_model,
max_tokens=query_parser.get_max_tokens_answer(),
query_context_images=prompt_context_images,
prefer_markdown=chat_request.prefer_markdown,
)
predict = get_predict()
nuclia_learning_id, predict_generator = await predict.chat_query(kbid, chat_model)
Expand Down
16 changes: 16 additions & 0 deletions nucliadb_models/nucliadb_models/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,11 @@ class SearchParamDefaults:
title="Rephrase query consuming LLMs",
description="Rephrase query consuming LLMs - it will make the query slower", # noqa
)
prefer_markdown = ParamDefault(
default=False,
title="Prefer markdown",
description="If set to true, the response will be in markdown format",
)


class Filter(BaseModel):
Expand Down Expand Up @@ -808,6 +813,11 @@ class ChatModel(BaseModel):
description="The information retrieval context for the current query, each image is a base64 encoded string",
)

prefer_markdown: bool = Field(
default=False,
description="If set to true, the response will be in markdown format",
)


class RephraseModel(BaseModel):
question: str
Expand Down Expand Up @@ -1027,6 +1037,12 @@ class ChatRequest(BaseModel):
description="Consume LLM tokens to rephrase the query so the semantic search is better",
)

prefer_markdown: bool = Field(
default=False,
title="Prefer markdown",
description="If set to true, the response will be in markdown format",
)

@root_validator(pre=True)
def rag_features_validator(cls, values):
chosen_strategies = []
Expand Down

3 comments on commit e0115a9

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: e0115a9 Previous: 1a9ce6c Ratio
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error 13202.976300385522 iter/sec (stddev: 1.9179574641045262e-7) 13339.058637295573 iter/sec (stddev: 1.296413027597777e-7) 1.01

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: e0115a9 Previous: 1a9ce6c Ratio
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error 12980.865663499917 iter/sec (stddev: 1.4164048902376022e-7) 13339.058637295573 iter/sec (stddev: 1.296413027597777e-7) 1.03

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: e0115a9 Previous: 1a9ce6c Ratio
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error 14064.452335143837 iter/sec (stddev: 3.431104664405144e-7) 13339.058637295573 iter/sec (stddev: 1.296413027597777e-7) 0.95

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.