Spaces:
Runtime error
Runtime error
Dmitry Kirsanov commited on
Commit ·
3300976
1
Parent(s): f09d6be
fixes
Browse files- llm.py +2 -1
- understand.py +3 -3
llm.py
CHANGED
|
@@ -86,7 +86,8 @@ class OpenAI(LLM):
|
|
| 86 |
max_tokens=self.max_output_tokens,
|
| 87 |
)
|
| 88 |
truncated = response.choices[0].finish_reason == 'length'
|
| 89 |
-
|
|
|
|
| 90 |
|
| 91 |
return response.choices[0].message.content, truncated
|
| 92 |
|
|
|
|
| 86 |
max_tokens=self.max_output_tokens,
|
| 87 |
)
|
| 88 |
truncated = response.choices[0].finish_reason == 'length'
|
| 89 |
+
if truncated:
|
| 90 |
+
print (f"Answer was truncated due to length (model name: {self.modelname}, max output tokens: {self.max_output_tokens}). Modify the instructions to produce a shorter answer or to give answer in parts.")
|
| 91 |
|
| 92 |
return response.choices[0].message.content, truncated
|
| 93 |
|
understand.py
CHANGED
|
@@ -52,13 +52,13 @@ Give a one-paragraph summary of the document's content. Write just one paragraph
|
|
| 52 |
|
| 53 |
for line in lines:
|
| 54 |
line = line.strip()
|
| 55 |
-
if line.strip()
|
|
|
|
|
|
|
| 56 |
if line.strip().upper() == what.upper():
|
| 57 |
inlist = True
|
| 58 |
else:
|
| 59 |
inlist = False
|
| 60 |
-
elif line.strip() == "":
|
| 61 |
-
inlist = False
|
| 62 |
elif inlist:
|
| 63 |
if line.startswith("- "):
|
| 64 |
item = line[2:].strip()
|
|
|
|
| 52 |
|
| 53 |
for line in lines:
|
| 54 |
line = line.strip()
|
| 55 |
+
if line.strip() == "":
|
| 56 |
+
inlist = False
|
| 57 |
+
elif line.strip()[-1] == ":":
|
| 58 |
if line.strip().upper() == what.upper():
|
| 59 |
inlist = True
|
| 60 |
else:
|
| 61 |
inlist = False
|
|
|
|
|
|
|
| 62 |
elif inlist:
|
| 63 |
if line.startswith("- "):
|
| 64 |
item = line[2:].strip()
|