feat: file url

pull/26/head
adldotori 1 year ago
parent 8b685d7261
commit 2a0177a0a0

@ -117,7 +117,7 @@ async def execute(request: ExecuteRequest) -> ExecuteResponse:
except Exception as e:
return {"answer": str(e), "files": []}
files = re.findall(r"\[file/\S*\]", res["output"])
files = re.findall(r"\[\S*\]", res["output"])
files = [file[1:-1] for file in files]
return {

@ -3,8 +3,8 @@ EVAL_PREFIX = """{bot_name} can execute any user's request.
{bot_name} has permission to handle one instance and can handle the environment in it at will.
You can code, run, debug, and test yourself. You can correct the code appropriately by looking at the error message.
I can understand, process, and create various types of files. Every image, dataframe, audio, video must be restored in file/ directory.
{bot_name} can do whatever it takes to execute the user's request. Let's think step by step.
Every input file must be stored in file/ directory. Every output file can be stored anywhere.
Let's think step by step.
"""
EVAL_FORMAT_INSTRUCTIONS = """RESPONSE FORMAT INSTRUCTIONS
@ -37,7 +37,8 @@ EVAL_SUFFIX = """TOOLS
{bot_name} can ask the user to use tools to look up information that may be helpful in answering the users original question.
You are very strict to the filename correctness and will never fake a file name if it does not exist.
You will remember to provide the file name loyally if it's provided in the last tool observation.
If you have to include files in your response, you must move the files into file/ directory and provide the filename in [file/FILENAME] format. It must be wrapped in square brackets.
If the response contains a file, it should be enclosed in square brackets.
ex. [example_filename.txt], [example_filename2.png]
The tools the human can use are:

@ -1,5 +1,13 @@
const setUrl = (answer) => {
return answer.replace(
/(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.?[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))/g,
(x) => '<a href="' + x + '">' + x + "</a>"
);
};
const setAnswer = (answer, files) => {
document.getElementById("answer").textContent = answer;
answer = setUrl(answer);
document.getElementById("answer").innerHTML = answer;
const filesDiv = document.getElementById("response-files");
filesDiv.innerHTML = "";
files.forEach((file) => {

Loading…
Cancel
Save