forked from seratch/ChatGPT-in-Slack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinternals_test.py
40 lines (36 loc) · 1.1 KB
/
internals_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from internals import format_assistant_reply, format_openai_message_content
def test_format_assistant_reply():
for (content, expected) in [
(
"\n\nSorry, I cannot answer the question.",
"Sorry, I cannot answer the question.",
),
("\n\n```python\necho 'foo'\n```", "```\necho 'foo'\n```"),
("\n\n```ruby\nputs 'foo'\n```", "```\nputs 'foo'\n```"),
(
"\n\n```java\nSystem.out.println(123);\n```",
"```\nSystem.out.println(123);\n```",
),
]:
result = format_assistant_reply(content)
assert result == expected
def test_format_openai_message_content():
# https://github.com/seratch/ChatGPT-in-Slack/pull/5
for (content, expected) in [
(
"""#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Hello, world!\n");
return 0;
}""",
"""#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Hello, world!\n");
return 0;
}""",
),
]:
result = format_openai_message_content(content)
assert result == expected