Skip to content

Commit

Permalink
Merge branch 'cohere-ai:main' into integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaytonSmith authored Jun 17, 2024
2 parents 8ff1b42 + 99e2994 commit 7a954d1
Show file tree
Hide file tree
Showing 54 changed files with 1,397 additions and 840 deletions.
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sse-starlette = "^2.0.0"
boto3 = "^1.0.0"
httpx = "^0.27.0"
chromadb = "^0.4.16"
cohere = "^5.5.6"
cohere = "^5.5.7"
llama-index = "^0.10.11"
inquirer = "^3.2.4"
langchain-community = "^0.0.32"
Expand Down
71 changes: 71 additions & 0 deletions src/backend/alembic/versions/3f207ae41477_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""empty message
Revision ID: 3f207ae41477
Revises: 922e874930bf
Create Date: 2024-06-15 23:02:22.350756
"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = "3f207ae41477"
down_revision: Union[str, None] = "922e874930bf"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"agents",
"tools",
existing_type=postgresql.ARRAY(sa.VARCHAR(length=24)),
type_=postgresql.ARRAY(sa.Text()),
existing_nullable=False,
)
op.alter_column(
"agents",
"model",
existing_type=sa.VARCHAR(length=14),
type_=sa.Text(),
existing_nullable=False,
)
op.alter_column(
"agents",
"deployment",
existing_type=sa.VARCHAR(length=15),
type_=sa.Text(),
existing_nullable=False,
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"agents",
"deployment",
existing_type=sa.Text(),
type_=sa.VARCHAR(length=15),
existing_nullable=False,
)
op.alter_column(
"agents",
"model",
existing_type=sa.Text(),
type_=sa.VARCHAR(length=14),
existing_nullable=False,
)
op.alter_column(
"agents",
"tools",
existing_type=postgresql.ARRAY(sa.Text()),
type_=postgresql.ARRAY(sa.VARCHAR(length=24)),
existing_nullable=False,
)
# ### end Alembic commands ###
14 changes: 9 additions & 5 deletions src/backend/chat/collate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from itertools import zip_longest
import json
from typing import Any, Dict, List

from backend.model_deployments.base import BaseDeployment

RELEVANCE_THRESHOLD = 0.5
RELEVANCE_THRESHOLD = 0.3


def rerank_and_chunk(
Expand Down Expand Up @@ -45,9 +45,9 @@ def rerank_and_chunk(
reranked_results = {}
for tool_call_hashable, tool_result in unified_tool_results.items():
tool_call = tool_result["call"]
query = tool_call.parameters.get("query") or tool_call.parameters.get(
"search_query"
)
query = tool_call.get("parameters").get("query") or tool_call.get(
"parameters"
).get("search_query")

# Only rerank if there is a query
if not query:
Expand Down Expand Up @@ -122,3 +122,7 @@ def chunk(content, compact_mode=False, soft_word_cut_off=100, hard_word_cut_off=
chunks.append(current_chunk.strip())

return chunks


def to_dict(obj):
return json.loads(json.dumps(obj, default=lambda o: o.__dict__))
Loading

0 comments on commit 7a954d1

Please sign in to comment.