Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs sprint] Add Docs on Creating and Using External Actions #18

Merged
merged 6 commits into from
Jun 14, 2024

Conversation

macwilk
Copy link
Collaborator

@macwilk macwilk commented Jun 10, 2024

Adds documentation on how to create and use External Actions using the OS Library.

Differs a good bit from the API version but I lifted a lot of the language from there and repurposed for Open Source.

@macwilk macwilk requested review from ajar98 and adnaans June 10, 2024 20:28
@macwilk macwilk changed the title Add Docs on Creating and Using External Actions [docs sprint] Add Docs on Creating and Using External Actions Jun 10, 2024
External Actions allow Vocode agents to take actions outside the realm of a phone call. In particular, Vocode agents can decide to _push_ information to external systems via an API request, and _pull_ information from the API response in order to:

1. change the agent’s behavior based on the pulled information
2. give the agent context to inform the rest of the phone call
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add that the agent can do things outside a phone call


#### Overview

- `processing_mode`: while it only supports `muted` right now, the intent is for this field to (in the future) enable hold music while processing the request, or to enable the agent to continue speaking until the request returns.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this detail?

- `url`: The API request is sent to this URL in the format
defined below in [Responding to External Action API Requests](/open-source/external-action#input-schema-field)

- `input_schema`: A [JSON Schema](https://json-schema.org/) object that instructs how to properly form a payload to send to the External API. See the [`input_schema` field section below](/open-source/external-action#responding-to-external-action-api-requests) for more info!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to "A JSON Schema for the payload to send to the external API.

Comment on lines 30 to 34
- `speak_on_send`: if `True`, then the underlying LLM will generate a message to be spoken into the phone call as the
API request is being sent.

- `speak_on_receive`: if `True`, then the Vocode Agent will invoke the underlying
LLM to respond based on the result from the API Response or the Error encountered.
Copy link
Collaborator

@adnaans adnaans Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For both, say the LLM will generate a message to be spoken into the phone call


#### `input_schema` Field

The `input_schema` field is a [JSON Schema](https://json-schema.org/) object that instructs how to properly form a payload to send to the External API.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"is a JSON Schema for the payload to send to the External API"

"""
signature_secret_as_bytes = base64.b64decode(signature_secret)
decoded_digest = base64.b64decode(request_signature_value)
calculated_digest = hmac.new(signature_secret_as_bytes, payload, hashlib.sha256).digest()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double check but payload may need to be encoded

Comment on lines 152 to 155
Response {
result: Any
agent_message: Optional[str] = None
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check indentation

```

- `result` is a payload containing the result of the action on the user’s side, and can be in any format
- `agent_message` optionally contains a message that will be synthesized into audio and sent back to the phone call (see [Configuring the External Action](/open-source/external-action#configuring-the-external-action) above for more info)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean the LLM isn't invoked at the end? need to clarify this

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's not invoked

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the docs accordingly then (earlier we say it always queries the LLM which is inaccurate then)

Comment on lines 188 to 192
class Payload(BaseModel):
length: str
time: str

call_id: str
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Comment on lines 197 to 199
print(f"Received request:\n{external_action_request.model_dump_json(indent=2)}")
time.sleep(3)
return {"result": {"success": True}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

"signature_secret": base64.b64encode(os.urandom(32)).decode(),
}

action = ExecuteExternalAction(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we link the Action Agents doc here? this isn't how you would use the action

also - in this PR can we update the the Action Agents or the Agent Factories doc to actually show how to insert a user created action into a conversation? both of those docs are missing that

ajar98
ajar98 previously approved these changes Jun 14, 2024
@adnaans adnaans merged commit 8f5e16a into main Jun 14, 2024
2 checks passed
adnaans pushed a commit that referenced this pull request Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants