Skip to content

Commit

Permalink
Add classification instruction (#130)
Browse files Browse the repository at this point in the history
* chore: Update classification request to labels from name

* feat: Add instruction parameter to classification request

* chore: Fix tests and linter

* chore: Revert label changes
  • Loading branch information
paul-paliychuk authored Mar 11, 2024
1 parent b7ed932 commit b149e59
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 3 additions & 4 deletions examples/ecommerce-chainlit/app.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import asyncio
import os
import uuid

import asyncio
import chainlit as cl
from chat_history_shoe_purchase import history as previous_chat_history
from dotenv import find_dotenv, load_dotenv
from openai import AsyncOpenAI

from zep_python import ZepClient
from zep_python.memory import Memory, Session
from zep_python.user import CreateUserRequest
from zep_python.message import Message

from chat_history_shoe_purchase import history as previous_chat_history
from zep_python.user import CreateUserRequest

load_dotenv(dotenv_path=find_dotenv())

Expand Down
8 changes: 8 additions & 0 deletions zep_python/memory/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ async def aclassify_session(
classes: List[str],
last_n: Optional[int] = None,
persist: Optional[bool] = True,
instruction: Optional[str] = None,
) -> ClassifySessionResponse:
"""
Classify the session with the specified ID. Asynchronous version.
Expand All @@ -323,6 +324,8 @@ async def aclassify_session(
persist : Optional[bool], optional
Whether to persist the classification to session metadata.
Defaults to True.
instruction : Optional[str], optional
Custom instruction to use for classification. Defaults to None.
Returns
-------
Expand Down Expand Up @@ -353,6 +356,7 @@ async def aclassify_session(
classes=classes,
last_n=last_n,
persist=persist,
instruction=instruction,
)

response = await self.aclient.post(
Expand All @@ -370,6 +374,7 @@ def classify_session(
classes: List[str],
last_n: Optional[int] = None,
persist: Optional[bool] = True,
instruction: Optional[str] = None,
) -> ClassifySessionResponse:
"""
Classify the session with the specified ID.
Expand All @@ -389,6 +394,8 @@ def classify_session(
persist : Optional[bool], optional
Whether to persist the classification to session metadata.
Defaults to True.
instruction : Optional[str], optional
Custom instruction to use for classification. Defaults to None.
Returns
-------
Expand Down Expand Up @@ -419,6 +426,7 @@ def classify_session(
classes=classes,
last_n=last_n,
persist=persist,
instruction=instruction,
)

response = self.client.post(
Expand Down
1 change: 1 addition & 0 deletions zep_python/memory/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class ClassifySessionRequest(BaseModel):
classes: List[str]
last_n: Optional[int] = None
persist: Optional[bool] = True
instruction: Optional[str] = None


class ClassifySessionResponse(BaseModel):
Expand Down

0 comments on commit b149e59

Please sign in to comment.