Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Dec 12, 2024
2 parents 069a919 + c3b2850 commit 0e72748
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 190 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ Conversation options are represented as features. They can be configured from Ap
| `recognition_retry_max` | The maximum number of retries for voice recognition. | `int` | 2 |
| `recording_enabled` | Whether call recording is enabled. | `bool` | false |
| `slow_llm_for_chat` | Whether to use the slow LLM for chat. | `bool` | false |
| `vad_cutoff_timeout_ms` | The cutoff timeout for voice activity detection in secs. | `int` | 150 |
| `vad_cutoff_timeout_ms` | The cutoff timeout for voice activity detection in secs. | `int` | 250 |
| `vad_silence_timeout_ms` | The timeout for phone silence in secs. | `int` | 500 |
| `vad_threshold` | The threshold for voice activity detection. | `float` | 0.5 |

Expand Down
16 changes: 11 additions & 5 deletions app/helpers/call_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ async def _stop_callback() -> None:

async def _commit_answer(
wait: bool,
tool_blacklist: set[str] | None = None,
tool_blacklist: set[str] = set(),
) -> None:
"""
Process the response.
Expand Down Expand Up @@ -289,9 +289,9 @@ async def _continue_chat( # noqa: PLR0915, PLR0913
client: CallAutomationClient,
post_callback: Callable[[CallStateModel], Awaitable[None]],
scheduler: Scheduler,
tool_blacklist: set[str] | None,
training_callback: Callable[[CallStateModel], Awaitable[None]],
tts_client: SpeechSynthesizer,
tool_blacklist: set[str] = set(),
_iterations_remaining: int = 3,
) -> CallStateModel:
"""
Expand Down Expand Up @@ -482,7 +482,7 @@ async def _generate_chat_completion( # noqa: PLR0913, PLR0911, PLR0912, PLR0915
client: CallAutomationClient,
post_callback: Callable[[CallStateModel], Awaitable[None]],
scheduler: Scheduler,
tool_blacklist: set[str] | None,
tool_blacklist: set[str],
tts_callback: Callable[[str, MessageStyleEnum], Awaitable[None]],
tts_client: SpeechSynthesizer,
use_tools: bool,
Expand Down Expand Up @@ -539,7 +539,7 @@ async def _content_callback(buffer: str) -> None:
if not use_tools:
logger.warning("Tools disabled for this chat")
else:
tools = await plugins.to_openai(tool_blacklist)
tools = await plugins.to_openai(frozenset(tool_blacklist))
# logger.debug("Tools: %s", tools)

# Execute LLM inference
Expand Down Expand Up @@ -626,7 +626,13 @@ async def _content_callback(buffer: str) -> None:
scheduler=scheduler,
):
await asyncio.gather(
*[plugins.execute_tool(tool_call) for tool_call in tool_calls]
*[
plugins.execute(
blacklist=tool_blacklist,
tool=tool_call,
)
for tool_call in tool_calls
]
)

# Update call model if object reference changed
Expand Down
5 changes: 3 additions & 2 deletions app/helpers/config_models/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class LlmModel(BaseModel):
- Provide a clear and concise summary of the conversation at the beginning of each call
- Respond only if it is related to the objective or the claim
- To list things, use bullet points or numbered lists
- Use a lot of discourse markers, fillers, to make the conversation human-like
- Use a lot of discourse markers, fillers, to make the conversation human-like (e.g., "Well, let me think...", "So, what I can do for you is...", "I see, you are in Paris...")
- Use short sentences and simple words
- Use tools as often as possible and describe the actions you take
- When the customer says a word and then spells out letters, this means that the word is written in the way the customer spelled it (e.g., "I live in Paris PARIS" -> "Paris", "My name is John JOHN" -> "John", "My email is Clemence CLEMENCE at gmail dot com" -> "[email protected]")
- Work for {bot_company}, not someone else
Expand Down Expand Up @@ -147,7 +148,7 @@ class LlmModel(BaseModel):
Conversation objective: Fill the claim with the customer. Claim is about a car accident.
User: action=talk I had an accident this morning, I was shopping. Let me send the exact location by SMS.
User: action=sms At the corner of Rue de la Paix and Rue de Rivoli.
Tools: update incident location,n
Tools: update incident location
Assistant: style=sad I get it, you had an accident this morning while shopping. style=none I have updated your file with the location you sent me by SMS. style=cheerful Is it correct?
## Example 7
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def vad_silence_timeout_ms(scheduler: Scheduler) -> int:

async def vad_cutoff_timeout_ms(scheduler: Scheduler) -> int:
return await _default(
default=150,
default=250,
key="vad_cutoff_timeout_ms",
scheduler=scheduler,
type_res=int,
Expand Down
Loading

0 comments on commit 0e72748

Please sign in to comment.