langchainの画像生成タグの終端を変更
parent
7b010518e3
commit
ca6509c184
|
|
@ -123,14 +123,14 @@ class LangChainApi:
|
|||
You also have the function to generate image with Stable Diffusion.
|
||||
If you want to use this function, please add the following to your message.
|
||||
|
||||

|
||||

|
||||
|
||||
PROMPT contains the prompt to generate the image.
|
||||
Prompt is comma separated keywords.
|
||||
If it is not in English, please translate it into English (lang:en).
|
||||
For example, if you want to output "a school girl wearing a red ribbon", it would be as follows.
|
||||
|
||||

|
||||

|
||||
|
||||
The image is always output at the end, not at the location where it is added.
|
||||
If there are multiple entries, only the first one will be reflected.
|
||||
|
|
@ -171,7 +171,7 @@ If you understand, please reply to the following:<|end_of_turn|>
|
|||
if mes['role'] == 'user':
|
||||
history.add_user_message(mes['content'])
|
||||
elif mes['role'] == 'assistant':
|
||||
add_mes = re.sub("\(Generated image by the following prompt: (.*)\)", r'', mes['content'])
|
||||
add_mes = re.sub("\(Generated image by the following prompt: (.*)\)", r'', mes['content'])
|
||||
history.add_ai_message(add_mes)
|
||||
self.memory.chat_memory = history
|
||||
elif chatgpt_messages['log_version'] == 2:
|
||||
|
|
@ -187,7 +187,7 @@ If you understand, please reply to the following:<|end_of_turn|>
|
|||
if isinstance(mes, HumanMessage):
|
||||
ret_messages.append({"role": "user", "content": mes.content})
|
||||
elif isinstance(mes, AIMessage):
|
||||
add_mes = re.sub('\!\[sd-prompt\: (.*?)\]\(sd\://\)', r'(Generated image by the following prompt: \1)', mes.content)
|
||||
add_mes = re.sub('\!\[sd-prompt\: (.*?)\]\(sd\:// "result"\)', r'(Generated image by the following prompt: \1)', mes.content)
|
||||
ret_messages.append({"role": "assistant", "content": add_mes})
|
||||
return json.dumps(ret_messages)
|
||||
#dicts = {'log_version': 2}
|
||||
|
|
@ -248,9 +248,9 @@ If you understand, please reply to the following:<|end_of_turn|>
|
|||
ret_message = full_message
|
||||
prompt = None
|
||||
for tag in prompt_tags:
|
||||
if tag.startswith(''):
|
||||
if tag.startswith(''):
|
||||
if prompt is None:
|
||||
prompt = tag[len('')]
|
||||
prompt = tag[len('')]
|
||||
ret_message = ret_message.replace(tag, '_' + prompt + '_')
|
||||
if ret_message.isspace():
|
||||
return None, prompt
|
||||
|
|
|
|||
Loading…
Reference in New Issue