Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
kichanyurd committed Dec 19, 2024
2 parents a52f425 + 6a8a503 commit 4338067
Show file tree
Hide file tree
Showing 38 changed files with 943 additions and 428 deletions.
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,47 @@
All notable changes to Parlant will be documented here.

## [Unreleased]

None


## [1.2.0] - 2024-12-19

### Added
- Expose deletion flag for events in Session API

### Changed
- Print traceback when reporting server boot errors
- Make cancelled operations issue a warning rather than an error

### Fixed
- Fixed tool calling with optional parameters
- Fixed sandbox UI issues with message regeneration and status icon
- Fixed case where guideline is applied due to condition being partially applied

### Removed

None


## [1.1.0] - 2024-12-18

### Added

- Customer selection in sandbox Chat UI
- Support tool calls with freshness rules for context variables
- Add support for loading external modules for changing engine behavior programatically
- CachedSchematicGenerator to run the test suite more quickly
- TransientVectorDatabase to run the test suite more quickly

### Changed

- Changed model path for Chroma documents. You may need to delete your `runtime-data` dir.

### Fixed

- Improve handling of partially fulfilled guidelines

### Removed
None

None
16 changes: 8 additions & 8 deletions poetry.lock

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

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "parlant"
version = "1.1.0"
version = "1.2.0"
license = "Apache-2.0"
description = ""
authors = ["Yam Marcovitz <[email protected]>", "Dor Zohar <[email protected]>"]
Expand Down Expand Up @@ -47,6 +47,7 @@ tenacity = "^8.4.2"
tiktoken = "^0.7.0"
together = "^1.2.12"
tokenizers = "^0.20"
toml = "^0.10.2"
torch = "^2.5.1"
transformers = "^4.46.2"
types-aiofiles = "^24.1.0.20240626"
Expand All @@ -56,10 +57,10 @@ uvicorn = "^0.32.1"
nano-vectordb = "^0.0.4.3"
structlog = "^24.4.0"
colorama = "^0.4.6"
parlant-client = "^0.8"
parlant-client = "*"

[tool.poetry.group.dev.dependencies]
parlant-client = { git = "https://github.com/emcie-co/parlant-client-python.git", tag = "v0.8.0" }
parlant-client = { git = "https://github.com/emcie-co/parlant-client-python.git", tag = "v0.9.0" }
ipython = "^8.26.0"
mypy = "^1.11.1"
pep8-naming = "^0.13.3"
Expand All @@ -71,7 +72,6 @@ pytest-stochastics = "^0.4.4"
pytest-tap = "^3.4"
python-dotenv = "^1.0.1"
ruff = "^0.5.6"
toml = "^0.10.2"
types-python-dateutil = "^2.8.19.20240106"
types-requests = "^2.32.0.20240712"

Expand Down
8 changes: 0 additions & 8 deletions src/parlant/adapters/nlp/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import tiktoken

from parlant.adapters.nlp.common import normalize_json_output
from parlant.core.engines.alpha.tool_caller import ToolCallInferenceSchema
from parlant.core.logging import Logger
from parlant.core.nlp.policies import policy, retry
from parlant.core.nlp.tokenization import EstimatingTokenizer
Expand All @@ -43,7 +42,6 @@
from parlant.core.nlp.generation import (
T,
SchematicGenerator,
FallbackSchematicGenerator,
GenerationInfo,
SchematicGenerationResult,
UsageInfo,
Expand Down Expand Up @@ -369,12 +367,6 @@ def __init__(

@override
async def get_schematic_generator(self, t: type[T]) -> OpenAISchematicGenerator[T]:
if t == ToolCallInferenceSchema:
return FallbackSchematicGenerator(
GPT_4o_Mini[t](self._logger), # type: ignore
GPT_4o[t](self._logger), # type: ignore
logger=self._logger,
)
return GPT_4o[t](self._logger) # type: ignore

@override
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/parlant/api/chat/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Parlant Chatbot">
<title>Parlant</title>
<script type="module" crossorigin src="/chat/assets/index-BHKhp8nm.js"></script>
<script type="module" crossorigin src="/chat/assets/index-BinoUHav.js"></script>
<link rel="stylesheet" crossorigin href="/chat/assets/index-C4KihbFp.css">
</head>
<body>
Expand Down
15 changes: 9 additions & 6 deletions src/parlant/api/chat/src/components/chat/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ export default function Chat(): ReactElement {
setShowTyping(false);
};

const regenerateMessageDialog = (index: number) => (sessionId: string, offset: number) => {
const regenerateMessageDialog = (index: number) => (sessionId: string) => {
const isLastMessage = index === messages.length - 1;
if (isLastMessage) return regenerateMessage(index, sessionId, offset);
const lastUserMessageOffset = messages[index - 1].offset;
if (isLastMessage) return regenerateMessage(index, sessionId, lastUserMessageOffset + 1);


const onApproved = () => {
closeQuestionDialog();
regenerateMessage(index, sessionId, offset);
regenerateMessage(index, sessionId, lastUserMessageOffset + 1);
};

const question = 'Regenerating this message would cause all of the following messages in the session to disappear.';
Expand All @@ -95,7 +97,7 @@ export default function Chat(): ReactElement {
const prevLastOffset = lastOffset;

setMessages(messages => messages.slice(0, index));
setLastOffset(offset - 1);
setLastOffset(offset);
setIsRegenerating(true);
const deleteSession = await deleteData(`sessions/${sessionId}/events?min_offset=${offset}`).catch((e) => ({error: e}));
if (deleteSession?.error) {
Expand Down Expand Up @@ -128,9 +130,10 @@ export default function Chat(): ReactElement {
if (!lastEvent) return;
const offset = lastEvent?.offset;
if (offset || offset === 0) setLastOffset(offset + 1);
const correlationsMap = groupBy(lastMessages || [], (item: EventInterface) => item?.correlation_id.split('.')[0]);
const correlationsMap = groupBy(lastMessages || [], (item: EventInterface) => item?.correlation_id.split('::')[0]);
const newMessages = lastMessages?.filter(e => e.kind === 'message') || [];
const withStatusMessages = newMessages.map(newMessage => ({...newMessage, serverStatus: correlationsMap?.[newMessage.correlation_id.split('.')[0]]?.at(-1)?.data?.status}));
const withStatusMessages = newMessages.map((newMessage, i) =>
({...newMessage, serverStatus: correlationsMap?.[newMessage.correlation_id.split('::')[0]]?.at(-1)?.data?.status || (newMessages[i + 1] ? 'ready' : null)}));
if (newMessages.length && isRegenerating) setIsRegenerating(false);

if (pendingMessage.serverStatus !== 'pending' && pendingMessage.data.message) setPendingMessage(emptyPendingMessage);
Expand Down
4 changes: 2 additions & 2 deletions src/parlant/api/chat/src/components/message/message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface Props {
event: EventInterface;
isContinual: boolean;
isRegenerateHidden?: boolean;
regenerateMessageFn?: (sessionId: string, offset: number) => void;
regenerateMessageFn?: (sessionId: string) => void;
}

const statusIcon = {
Expand Down Expand Up @@ -54,7 +54,7 @@ export default function Message({event, isContinual, isRegenerateHidden, regener
{!isClient &&
<div className={twMerge('self-stretch items-center px-[16px] flex invisible peer-hover:visible hover:visible', isRegenerateHidden && 'hidden')}>
<Tooltip value='Regenerate' side='right'>
<div data-testid='regenerate-button'role='button' onClick={() => regenerateMessageFn?.(sessionId as string, event.offset)} className='group cursor-pointer'>
<div data-testid='regenerate-button'role='button' onClick={() => regenerateMessageFn?.(sessionId as string)} className='group cursor-pointer'>
<img src="icons/regenerate.svg" alt="regenerate" className='block group-hover:hidden'/>
<img src="icons/regenerate-filled.svg" alt="regenerate" className='hidden group-hover:block'/>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/parlant/api/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ class EventDTO(
creation_utc: EventCreationUTCField
correlation_id: EventCorrelationIdField
data: JSONSerializableDTO
deleted: bool


class ConsumptionOffsetsUpdateParamsDTO(
Expand Down Expand Up @@ -817,6 +818,7 @@ def event_to_dto(event: Event) -> EventDTO:
creation_utc=event.creation_utc,
correlation_id=event.correlation_id,
data=cast(JSONSerializableDTO, event.data),
deleted=event.deleted,
)


Expand Down Expand Up @@ -1362,6 +1364,7 @@ async def _add_human_agent_message_on_behalf_of_ai_agent(
creation_utc=event.creation_utc,
correlation_id=event.correlation_id,
data=cast(JSONSerializableDTO, event.data),
deleted=event.deleted,
)

@router.get(
Expand Down Expand Up @@ -1443,6 +1446,7 @@ async def list_events(
creation_utc=e.creation_utc,
correlation_id=e.correlation_id,
data=cast(JSONSerializableDTO, e.data),
deleted=e.deleted,
)
for e in events
]
Expand Down
1 change: 1 addition & 0 deletions src/parlant/bin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ def _render_events(events: list[Event]) -> None:
"Offset": e.offset,
"Kind": e.kind,
"Data": e.data,
"Deleted": e.deleted,
}
for e in events
]
Expand Down
2 changes: 2 additions & 0 deletions src/parlant/bin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from dataclasses import dataclass
import importlib
import os
import traceback
from lagom import Container, Singleton
from typing import AsyncIterator, Callable, Iterable
import toml
Expand Down Expand Up @@ -448,6 +449,7 @@ async def serve_app(
except (KeyboardInterrupt, asyncio.CancelledError):
await BACKGROUND_TASK_SERVICE.cancel_all(reason="Server shutting down")
except BaseException as e:
LOGGER.critical(traceback.format_exc())
LOGGER.critical(e.__class__.__name__ + ": " + str(e))
sys.exit(1)

Expand Down
2 changes: 1 addition & 1 deletion src/parlant/core/engines/alpha/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ async def _do_process(
total_duration=guideline_proposition_result.total_duration,
batches=guideline_proposition_result.batch_generations,
),
tool_calls=[tool_event_generation_result.generation_info]
tool_calls=tool_event_generation_result.generations
if tool_event_generation_result
else [],
),
Expand Down
25 changes: 0 additions & 25 deletions src/parlant/core/engines/alpha/event_generation.py

This file was deleted.

Loading

0 comments on commit 4338067

Please sign in to comment.