Skip to content

Commit

Permalink
feat(product-assistant): use async_except_on_cache_miss in assistant …
Browse files Browse the repository at this point in the history
…queries (#25828)
  • Loading branch information
skoob13 authored Oct 28, 2024
1 parent 1afccff commit e5957b6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ee/hogai/trends/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def _model(self) -> ChatOpenAI:
@cached_property
def _events_prompt(self) -> str:
response = TeamTaxonomyQueryRunner(TeamTaxonomyQuery(), self._team).run(
ExecutionMode.RECENT_CACHE_CALCULATE_BLOCKING_IF_STALE
ExecutionMode.RECENT_CACHE_CALCULATE_ASYNC_IF_STALE_AND_BLOCKING_ON_MISS
)

if not isinstance(response, CachedTeamTaxonomyQueryResponse):
Expand Down
6 changes: 3 additions & 3 deletions ee/hogai/trends/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def retrieve_event_properties(self, event_name: str) -> str:
Retrieve properties for an event.
"""
runner = EventTaxonomyQueryRunner(EventTaxonomyQuery(event=event_name), self._team)
response = runner.run(ExecutionMode.RECENT_CACHE_CALCULATE_BLOCKING_IF_STALE)
response = runner.run(ExecutionMode.RECENT_CACHE_CALCULATE_ASYNC_IF_STALE_AND_BLOCKING_ON_MISS)

if not isinstance(response, CachedEventTaxonomyQueryResponse):
return "Properties have not been found."
Expand Down Expand Up @@ -352,7 +352,7 @@ def retrieve_event_property_values(self, event_name: str, property_name: str) ->
return f"The property {property_name} does not exist in the taxonomy."

runner = EventTaxonomyQueryRunner(EventTaxonomyQuery(event=event_name), self._team)
response = runner.run(ExecutionMode.RECENT_CACHE_CALCULATE_BLOCKING_IF_STALE)
response = runner.run(ExecutionMode.RECENT_CACHE_CALCULATE_ASYNC_IF_STALE_AND_BLOCKING_ON_MISS)

if not isinstance(response, CachedEventTaxonomyQueryResponse):
return f"The event {event_name} does not exist in the taxonomy."
Expand Down Expand Up @@ -426,7 +426,7 @@ def retrieve_entity_property_values(self, entity: str, property_name: str) -> st
return f"The property {property_name} does not exist in the taxonomy for the entity {entity}."

response = ActorsPropertyTaxonomyQueryRunner(query, self._team).run(
ExecutionMode.RECENT_CACHE_CALCULATE_BLOCKING_IF_STALE
ExecutionMode.RECENT_CACHE_CALCULATE_ASYNC_IF_STALE_AND_BLOCKING_ON_MISS
)

if not isinstance(response, CachedActorsPropertyTaxonomyQueryResponse):
Expand Down
2 changes: 1 addition & 1 deletion posthog/api/test/__snapshots__/test_api_docs.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
'/home/runner/work/posthog/posthog/posthog/api/survey.py: Warning [SurveyViewSet > SurveySerializer]: unable to resolve type hint for function "get_conditions". Consider using a type hint or @extend_schema_field. Defaulting to string.',
'/home/runner/work/posthog/posthog/posthog/api/web_experiment.py: Warning [WebExperimentViewSet]: could not derive type of path parameter "project_id" because model "posthog.models.web_experiment.WebExperiment" contained no such field. Consider annotating parameter with @extend_schema. Defaulting to "string".',
'Warning: encountered multiple names for the same choice set (HrefMatchingEnum). This may be unwanted even though the generated schema is technically correct. Add an entry to ENUM_NAME_OVERRIDES to fix the naming.',
'Warning: enum naming encountered a non-optimally resolvable collision for fields named "kind". The same name has been used for multiple choice sets in multiple components. The collision was resolved with "KindCfaEnum". add an entry to ENUM_NAME_OVERRIDES to fix the naming.',
'Warning: enum naming encountered a non-optimally resolvable collision for fields named "kind". The same name has been used for multiple choice sets in multiple components. The collision was resolved with "Kind069Enum". add an entry to ENUM_NAME_OVERRIDES to fix the naming.',
'Warning: enum naming encountered a non-optimally resolvable collision for fields named "kind". The same name has been used for multiple choice sets in multiple components. The collision was resolved with "KindCfaEnum". add an entry to ENUM_NAME_OVERRIDES to fix the naming.',
'Warning: enum naming encountered a non-optimally resolvable collision for fields named "type". The same name has been used for multiple choice sets in multiple components. The collision was resolved with "TypeF73Enum". add an entry to ENUM_NAME_OVERRIDES to fix the naming.',
'Warning: encountered multiple names for the same choice set (EffectivePrivilegeLevelEnum). This may be unwanted even though the generated schema is technically correct. Add an entry to ENUM_NAME_OVERRIDES to fix the naming.',
'Warning: encountered multiple names for the same choice set (MembershipLevelEnum). This may be unwanted even though the generated schema is technically correct. Add an entry to ENUM_NAME_OVERRIDES to fix the naming.',
Expand Down

0 comments on commit e5957b6

Please sign in to comment.