Spaces:
Runtime error
Runtime error
Update palmapi.py
Browse files- palmapi.py +22 -11
palmapi.py
CHANGED
@@ -25,17 +25,28 @@ class PaLMChatPromptFmt(PromptFmt):
|
|
25 |
@classmethod
|
26 |
def prompt(cls, pingpong, truncate_size):
|
27 |
ping = pingpong.ping[:truncate_size]
|
28 |
-
pong =
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
class PaLMChatPPManager(PPManager):
|
41 |
def build_prompts(self, from_idx: int=0, to_idx: int=-1, fmt: PromptFmt=PaLMChatPromptFmt, truncate_size: int=None):
|
|
|
25 |
@classmethod
|
26 |
def prompt(cls, pingpong, truncate_size):
|
27 |
ping = pingpong.ping[:truncate_size]
|
28 |
+
pong = pingpong.pong
|
29 |
+
|
30 |
+
if pong is None:
|
31 |
+
return [
|
32 |
+
{
|
33 |
+
"author": "USER",
|
34 |
+
"content": ping
|
35 |
+
},
|
36 |
+
]
|
37 |
+
else:
|
38 |
+
pong = pong[:truncate_size]
|
39 |
+
|
40 |
+
return [
|
41 |
+
{
|
42 |
+
"author": "USER",
|
43 |
+
"content": ping
|
44 |
+
},
|
45 |
+
{
|
46 |
+
"author": "AI",
|
47 |
+
"content": pong
|
48 |
+
},
|
49 |
+
]
|
50 |
|
51 |
class PaLMChatPPManager(PPManager):
|
52 |
def build_prompts(self, from_idx: int=0, to_idx: int=-1, fmt: PromptFmt=PaLMChatPromptFmt, truncate_size: int=None):
|