-
Notifications
You must be signed in to change notification settings - Fork 20
Llm integration POC #1028
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
base: main
Are you sure you want to change the base?
Llm integration POC #1028
Conversation
…s allowed token count. Make conflicting libraries pydantic-ai and ag-ui optional; disabling agent route if not installed. Make search routes async and fix small bugs in query building.
CodSpeed Performance ReportMerging #1028 will not alter performanceComparing 🎉 Hooray!
|
…hestrator-core into llm-integration
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1028 +/- ##
==========================================
- Coverage 84.93% 80.62% -4.31%
==========================================
Files 214 245 +31
Lines 10408 11685 +1277
Branches 1020 1144 +124
==========================================
+ Hits 8840 9421 +581
- Misses 1295 2008 +713
+ Partials 273 256 -17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
db_model: Any, | ||
response_schema: Type[BaseModel], | ||
pk_column_name: str, | ||
eager_loads: List[Any], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just out of curiosity: is there a reason that these 'old style' types are used? list vs List, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, just an old habit from me I guess. I see that the package enforces python >= 3.11, so I can take a look to remove all older style types, I think from 3.10 onwards alot of types I used here are not necessary anymore 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
@@ -83,3 +84,5 @@ | |||
tags=["Core", "Translations"], | |||
) | |||
api_router.include_router(ws.router, prefix="/ws", tags=["Core", "Events"]) | |||
|
|||
api_router.include_router(search.router) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tags=["Search"]? And should we add prefix = /search (and update the search router accordingly)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see you have it in the other file. Maybe that should be moved here to keep the "overview" of how routes are mounted in this file.
dotenv run python main.py search semantic "Shop for an alligator store" | ||
... | ||
{ | ||
"path": "subscription.shop.shop_description", | ||
"value": "Kingswood reptiles shop" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make the examples more generic (also the ones below), since this is specific for the WFO instance where we built the initial POC.
IDX_VALUE_TRGM = "ix_flat_value_trgm" | ||
IDX_CONTENT_HASH = "idx_ai_search_index_content_hash" | ||
|
||
TARGET_DIM = int(os.environ.get("EMBEDDING_DIMENSION", 1536)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed this with you and Rene during standup, this migration probably needs to be turned into a script so it can be re-run when a different model is chosen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do that but there needs to be a default vector field right. So once you run a second script to alter the column the migration will give conflicts.
I guess we can default it to 1536, the size of embeddings for openai text-embedding model(large).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default 1536 👍
### Step back to the revision right before the dynamic-dimension migration | ||
|
||
```bash | ||
dotenv run python main.py db downgrade 850dccac3b02 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented before that we needed a script for this, but does this mean you can run this migration independent from all other migrations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you can downgrade a specific migration and upgrade it again, essentially achieving the same as a cli script.
FilterCondition = ( | ||
DateFilter # DATETIME | ||
| NumericFilter # INT/FLOAT | ||
| StringFilter # STRING TODO: convert to hybrid search |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to make a ticket for this TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im thinking that maybe this stringfilter should be removed altogether, its already possible to do a hybrid search by passing a user query, passing something like the top 5 results back to the agent will probably yield better results.
For things like booleans/product blocks , we already have the equality filter. Matching on exact text by letting the agent fill in a string will probably not work well.
from orchestrator.search.schemas.parameters import BaseSearchParameters | ||
|
||
|
||
class QueryBuilder: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit nitpicky, but: this technically doesn't need to be a class, can be done with plain functions (you're not really using self
).
pydantic-ai
andag-ui-protocol
need
pydantic >= 2.10
and>=2.11.2
respectively, this breaks some of the unit tests