#Report bug on certain input format

1 messages · Page 1 of 1 (latest)

grim horizon
#

Please follow the bug report format below. Copy and paste the following text into a new post and complete all the fields. You may also attach screenshots if necessary.


**Steps to reproduce:**
> 1. use the chunk.json as the input 
> 2. 
run the following code

from langchain import PromptTemplate
from langchain.chat_models import ChatOpenAI
from langchain.chains.llm import LLMChain
import ast
map_template = """{messages}
Considering the provided chat history, identify and return the 10 most meaningful and informative messages in a JSON array format.
A completed and closed JSON array of length 10:
"""
map_prompt = PromptTemplate.from_template(map_template)
llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo-16k")
llm_chain = LLMChain(llm=llm, prompt=map_prompt)
import json
with open('chunk.json') as f:
    chunk = json.load(f)
rst = llm_chain.predict(messages=chunk)
rst = ast.literal_eval(rst)
print(rst)

**Expected result:**
>
[{'content': '對,要一直投錢下去蓋廠,資本支出很大\n台積電也是', 'user_id': '803928508212445225', 'message_id': '1135217750864822303'}, ....


**Actual result:**
> 
Traceback (most recent call last):
st.py:50 in parse
    return compile(source, filename, mode, flags,
...
  File <unknown>:1
    [{'content': '對,要一直投錢下去蓋廠,資本支出很大\n台積電也是', 'user_id': '803928508212445225', 'message_id': '1135217750864822303'}, {'content': '直接买这个就好啦', 'user_id': '907289224158539796', 'message_id': '1135217735605952552'}, {'content': 'Etf', 'user_id': '907289...
                                                                                                                                                                                                                                                  ^
SyntaxError: unterminated string literal (detected at line 1)