Skip to content

Commit 1eedcb1

Browse files
committed
chore: update to include the events hook + chat history
1 parent c67ff92 commit 1eedcb1

File tree

3 files changed

+72
-33
lines changed

3 files changed

+72
-33
lines changed

README.md

+55
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,65 @@ To run the events server, you can use the following command:
4848
npm run start:eventsServer
4949
```
5050

51+
If your `eventsHook` is set you will receive events from Fonoster including the chat history which will look like this:
52+
53+
```json
54+
{
55+
eventType: 'conversation.ended',
56+
chatHistory: [
57+
{
58+
ai: "Hello, I'm the Awesome Autopilot, how can I help you today?"
59+
},
60+
{ human: 'trying to find out what the meaning of life' },
61+
{ ai: "Before we dive into that, what's your name?" },
62+
{ human: 'My name is John Doe' },
63+
{
64+
ai: 'Hello John Doe. Life is a journey of love, laughter, and learning. Anything else I can help you with?'
65+
},
66+
{ human: 'No that is all' },
67+
{ ai: 'Thank you for your time. Have a great day!' }
68+
]
69+
}
70+
```
71+
5172
This will start the events server on port `3000`. You will also need to run Ngrok to expose the events server to the internet. You can do this by running the following command:
5273

5374
```bash
5475
ngrok http 3000
5576
```
5677

5778
This will expose the events server to the internet and you can use the URL returned by Ngrok to test the events server.
79+
80+
81+
82+
## Run the test cases
83+
84+
Firt, make sure to set the `apiKey` for the language model and the evals provider in the `appConfig.yaml` file.
85+
86+
Then, you use the following command to run the test cases:
87+
88+
```bash
89+
fonoster utils:autopilotTestsCases -f appConfig.yaml
90+
```
91+
92+
Your output should be similar to the following:
93+
94+
```
95+
Scenario: test-case-1
96+
Overall Passed: ✔
97+
┌──────┬────────────────────────────┬────────────────────────────┬────────────────────────────┬────────────┬────────┐
98+
│ Step │ Human Input │ Expected │ AI Response │ Tool Calls │ Passed │
99+
├──────┼────────────────────────────┼────────────────────────────┼────────────────────────────┼────────────┼────────┤
100+
│ 1 │ I want to learn about the │ Ok, but first, what's your │ Before we dive into that, │ │ ✔ │
101+
│ │ meaning of life. │ name? │ what's your name? │ │ │
102+
├──────┼────────────────────────────┼────────────────────────────┼────────────────────────────┼────────────┼────────┤
103+
│ 2 │ My name is John Doe. │ Great to meet you John │ Hello John Doe. Life is a │ │ ✔ │
104+
│ │ │ Doe. Life is a journey of │ journey of love, laughter, │ │ │
105+
│ │ │ love, laughter, and │ and learning. Is there │ │ │
106+
│ │ │ learning. Anything else I │ anything else I can help │ │ │
107+
│ │ │ can help you with? │ you with? │ │ │
108+
├──────┼────────────────────────────┼────────────────────────────┼────────────────────────────┼────────────┼────────┤
109+
│ 3 │ No, that's all. │ Thank you for your time. │ Thank you so much, bye! │ hangup() │ ✔ │
110+
│ │ │ Have a great day! │ │ │ │
111+
└──────┴────────────────────────────┴────────────────────────────┴────────────────────────────┴────────────┴────────┘
112+
```

appConfig.yaml

+16-23
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ intelligence:
1818
## Role
1919
You are an awesome assistant that can talk about anything. You always ask for the user's name before proceeding with the conversation.
2020
21+
## Instructions
22+
23+
Keep your answers short and concise as this is a phone call.
24+
2125
## Example Interaction
22-
Assistant: Hello, I'm the Awesome Autopilot, how can I help you today?
2326
User: I want to learn about the meaning of life.
2427
2528
Assistant: Ok, but first, what's your name?
2629
User: My name is John Doe.
2730
28-
Assistant: Hello John Doe. Life is a journey of love, laughter, and learning. (And use the `saveUserInfo` tool to save the user's name)
31+
Assistant: Hello John Doe. Life is a journey of love, laughter, and learning.
2932
User: That's a great answer! Thank you!
3033
3134
Assistant: You're welcome! Is there anything else I can help you with?
@@ -47,26 +50,20 @@ intelligence:
4750
timeout: 30
4851
languageModel:
4952
provider: "groq"
50-
model: "llama-3.1-70b-versatile"
53+
model: "llama-3.3-70b-versatile"
5154
maxTokens: 240
5255
temperature: 0.4
5356
apiKey: "REDACTED"
54-
tools:
55-
- name: "saveUserInfo"
56-
description: "Tool to save the user's name."
57-
parameters:
58-
type: "object"
59-
properties:
60-
name:
61-
type: "string"
62-
required:
63-
- name
64-
operation:
65-
method: "post"
66-
url: "https://82e4-47-132-130-31.ngrok-free.app/events"
67-
waitForResponse: false
68-
headers:
69-
x-api-key: "REDACTED"
57+
eventsHook:
58+
# TODO: Replace with your own URL
59+
url: "https://ac86-47-132-130-31.ngrok-free.app/events"
60+
headers:
61+
Content-Type: "application/json"
62+
Authorization: "Basic REDACTED"
63+
events: ["all"]
64+
65+
## TEST CASES
66+
7067
testCases:
7168
evalsLanguageModel:
7269
# Note: Only OpenAI is supported for evals
@@ -91,10 +88,6 @@ intelligence:
9188
text:
9289
type: "similar"
9390
response: "Great to meet you John Doe. Life is a journey of love, laughter, and learning. Anything else I can help you with?"
94-
tools:
95-
- tool: "saveUserInfo"
96-
parameters:
97-
name: "John Doe"
9891
- userInput: "No, that's all."
9992
expected:
10093
text:

src/eventsServer.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import express from "express";
22
const app = express();
3-
const port = 4000;
3+
const port = 3000;
44

55
app.use(express.json());
66

@@ -13,15 +13,6 @@ app.post("/events", (req, res) => {
1313
});
1414
});
1515

16-
app.get("/test", (req, res) => {
17-
console.log("Headers:", req.headers);
18-
console.log("Body:", req.body);
19-
20-
res.json({
21-
result: "we booked an appointment for your for Friday next week"
22-
});
23-
});
24-
2516
app.listen(port, () => {
2617
console.log(`The events server is listening on port ${port}`);
2718
});

0 commit comments

Comments
 (0)