Skip to content

Commit

Permalink
Merge pull request #958 from julep-ai/x/misc-fixes
Browse files Browse the repository at this point in the history
fix(agents-api): Miscellaneous fixes in `sessions`
  • Loading branch information
Vedantsahai18 authored Dec 14, 2024
2 parents 6e5de98 + 756a547 commit caa0b27
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
6 changes: 6 additions & 0 deletions agents-api/agents_api/models/chat/gather_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ async def gather_messages(
# MMR is not applied to text search
and recall_options.mode != "text"
):
# FIXME: This is a temporary fix to ensure that the MMR algorithm works.
# We shouldn't be having references without embeddings.
doc_references = [
doc for doc in doc_references if doc.snippet.embedding is not None
]

# Apply MMR
indices = maximal_marginal_relevance(
np.asarray(query_embedding),
Expand Down
4 changes: 3 additions & 1 deletion agents-api/agents_api/models/session/create_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@ def create_session(

create_query = """
# Insert the new session data into the 'session' table with the specified columns.
?[session_id, developer_id, situation, metadata, render_templates, token_budget, context_overflow] <- [[
?[session_id, developer_id, situation, metadata, render_templates, token_budget, context_overflow, recall_options] <- [[
$session_id,
$developer_id,
$situation,
$metadata,
$render_templates,
$token_budget,
$context_overflow,
$recall_options,
]]
:insert sessions {
Expand All @@ -122,6 +123,7 @@ def create_session(
render_templates,
token_budget,
context_overflow,
recall_options,
}
# Specify the data to return after the query execution, typically the newly created session's ID.
:returning
Expand Down
3 changes: 3 additions & 0 deletions agents-api/agents_api/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def mark_session_updated_query(developer_id: UUID | str, session_id: UUID | str)
token_budget,
context_overflow,
updated_at,
recall_options,
] :=
input[developer_id, session_id],
*sessions {{
Expand All @@ -105,6 +106,7 @@ def mark_session_updated_query(developer_id: UUID | str, session_id: UUID | str)
render_templates,
token_budget,
context_overflow,
recall_options,
@ 'END'
}},
updated_at = [floor(now()), true]
Expand All @@ -119,6 +121,7 @@ def mark_session_updated_query(developer_id: UUID | str, session_id: UUID | str)
render_templates,
token_budget,
context_overflow,
recall_options,
updated_at,
}}
"""
Expand Down
2 changes: 1 addition & 1 deletion integrations-service/integrations/models/spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class SpiderResponse(BaseModel):
content: Optional[str] = None
content: Optional[str | list[str]] = None
error: Optional[str] = None
status: Optional[int] = None
costs: Optional[dict[Any, Any]] = None
Expand Down
10 changes: 5 additions & 5 deletions integrations-service/integrations/utils/integrations/spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def get_api_key(setup: SpiderSetup) -> str:
def create_spider_response(pages: list[dict]) -> list[SpiderResponse]:
return [
SpiderResponse(
url=page.get("url", "Not available"),
content=(page.get("content") or "Not available").strip(),
error=page.get("error", "Not available"),
status=page.get("status", "Not available"),
costs=page.get("costs", "Not available"),
url=page.get("url"),
content=(page.get("content")),
error=page.get("error"),
status=page.get("status"),
costs=page.get("costs"),
)
for page in pages
]
Expand Down

0 comments on commit caa0b27

Please sign in to comment.