mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-24 12:26:01 +08:00
docs: cut version 1.9.0 (#12681)
* version-1.9.0-docs * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -0,0 +1,15 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files"
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
response = requests.request("DELETE", url, headers=headers)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,17 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = (
|
||||
f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/delete/{os.getenv('FLOW_ID', '')}/2024-12-30_15-19-43_your_file.txt"
|
||||
)
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
response = requests.request("DELETE", url, headers=headers)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,15 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files/{os.getenv('FILE_ID', '')}"
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
response = requests.request("DELETE", url, headers=headers)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,35 @@
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
|
||||
base = os.environ.get("LANGFLOW_URL", "")
|
||||
flow_id = os.environ.get("FLOW_ID", "")
|
||||
api_key = os.environ.get("LANGFLOW_API_KEY", "")
|
||||
|
||||
fixtures = Path(__file__).resolve().parents[2] / "fixtures"
|
||||
upload_path = Path(os.environ.get("SAMPLE_UPLOAD_FILE", str(fixtures / "sample-upload.txt")))
|
||||
|
||||
headers = {"accept": "application/json", "x-api-key": api_key}
|
||||
|
||||
upload = requests.post(
|
||||
f"{base}/api/v1/files/upload/{flow_id}",
|
||||
headers=headers,
|
||||
files={"file": (upload_path.name, upload_path.read_bytes(), "text/plain")},
|
||||
timeout=30,
|
||||
)
|
||||
upload.raise_for_status()
|
||||
meta = upload.json()
|
||||
file_name = meta["file_path"].split("/")[-1]
|
||||
|
||||
download = requests.get(
|
||||
f"{base}/api/v1/files/download/{flow_id}/{file_name}",
|
||||
headers=headers,
|
||||
timeout=30,
|
||||
)
|
||||
download.raise_for_status()
|
||||
|
||||
out_path = Path("downloaded_file.txt")
|
||||
out_path.write_bytes(download.content)
|
||||
print(json.dumps({"saved_bytes": len(download.content), "path": str(out_path), "upload": meta}))
|
||||
@ -0,0 +1,33 @@
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
|
||||
base = os.environ.get("LANGFLOW_URL", "")
|
||||
api_key = os.environ.get("LANGFLOW_API_KEY", "")
|
||||
|
||||
fixtures = Path(__file__).resolve().parents[2] / "fixtures"
|
||||
upload_path = Path(os.environ.get("SAMPLE_UPLOAD_FILE", str(fixtures / "sample-upload.txt")))
|
||||
|
||||
headers = {"accept": "application/json", "x-api-key": api_key}
|
||||
|
||||
upload = requests.post(
|
||||
f"{base}/api/v2/files",
|
||||
headers=headers,
|
||||
files={"file": (upload_path.name, upload_path.read_bytes(), "text/plain")},
|
||||
timeout=30,
|
||||
)
|
||||
upload.raise_for_status()
|
||||
file_id = upload.json()["id"]
|
||||
|
||||
download = requests.get(
|
||||
f"{base}/api/v2/files/{file_id}",
|
||||
headers=headers,
|
||||
timeout=30,
|
||||
)
|
||||
download.raise_for_status()
|
||||
|
||||
out_path = Path("downloaded_file.txt")
|
||||
out_path.write_bytes(download.content)
|
||||
print(json.dumps({"saved_bytes": len(download.content), "file_id": str(file_id), "path": str(out_path)}))
|
||||
@ -0,0 +1,30 @@
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from urllib.parse import quote
|
||||
|
||||
import requests
|
||||
|
||||
base = os.environ.get("LANGFLOW_URL", "")
|
||||
api_key = os.environ.get("LANGFLOW_API_KEY", "")
|
||||
|
||||
fixtures = Path(__file__).resolve().parents[2] / "fixtures"
|
||||
upload_path = Path(os.environ.get("SAMPLE_UPLOAD_FILE", str(fixtures / "sample-upload.txt")))
|
||||
|
||||
headers = {"accept": "application/json", "x-api-key": api_key}
|
||||
|
||||
upload = requests.post(
|
||||
f"{base}/api/v2/files",
|
||||
headers=headers,
|
||||
files={"file": (upload_path.name, upload_path.read_bytes(), "text/plain")},
|
||||
timeout=30,
|
||||
)
|
||||
upload.raise_for_status()
|
||||
file_id = upload.json()["id"]
|
||||
|
||||
new_name = os.environ.get("RENAMED_FILE_BASENAME", "renamed-sample-upload")
|
||||
url = f"{base}/api/v2/files/{file_id}?name={quote(new_name)}"
|
||||
|
||||
response = requests.put(url, headers=headers, timeout=30)
|
||||
response.raise_for_status()
|
||||
print(json.dumps(response.json()))
|
||||
@ -0,0 +1,15 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/list/{os.getenv('FLOW_ID', '')}"
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,15 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files"
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,24 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/run/{os.getenv('FLOW_ID', '')}"
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
payload = {
|
||||
"input_value": "what do you see?",
|
||||
"output_type": "chat",
|
||||
"input_type": "text",
|
||||
"tweaks": {
|
||||
"Read-File-1olS3": {"path": ["07e5b864-e367-4f52-b647-a48035ae7e5e/3a290013-fe1e-4d3d-a454-cacae81288f3.pdf"]}
|
||||
},
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, json=payload)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,23 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files"
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
files = {
|
||||
"file": open(os.getenv("SAMPLE_UPLOAD_FILE", "docs/docs/API-Reference/fixtures/sample-upload.txt"), "rb"),
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, files=files)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
|
||||
for _f in files.values():
|
||||
if hasattr(_f, "close"):
|
||||
_f.close()
|
||||
@ -0,0 +1,23 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/upload/{os.getenv('FLOW_ID', '')}"
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
files = {
|
||||
"file": open(os.getenv("SAMPLE_UPLOAD_FILE", "docs/docs/API-Reference/fixtures/sample-upload.txt"), "rb"),
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, files=files)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
|
||||
for _f in files.values():
|
||||
if hasattr(_f, "close"):
|
||||
_f.close()
|
||||
@ -0,0 +1,23 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files"
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
files = {
|
||||
"file": open(os.getenv("SAMPLE_UPLOAD_FILE", "docs/docs/API-Reference/fixtures/sample-upload.txt"), "rb"),
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, files=files)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
|
||||
for _f in files.values():
|
||||
if hasattr(_f, "close"):
|
||||
_f.close()
|
||||
@ -0,0 +1,15 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/users/whoami"
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,26 @@
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
|
||||
base = os.environ.get("LANGFLOW_URL", "")
|
||||
flow_id = os.environ.get("FLOW_ID", "")
|
||||
api_key = os.environ.get("LANGFLOW_API_KEY", "")
|
||||
|
||||
fixtures = Path(__file__).resolve().parents[2] / "fixtures"
|
||||
image_path = Path(os.environ.get("SAMPLE_IMAGE_FILE", str(fixtures / "sample-upload.png")))
|
||||
|
||||
headers = {"accept": "application/json", "x-api-key": api_key}
|
||||
|
||||
upload = requests.post(
|
||||
f"{base}/api/v1/files/upload/{flow_id}",
|
||||
headers=headers,
|
||||
files={"file": (image_path.name, image_path.read_bytes(), "image/png")},
|
||||
timeout=30,
|
||||
)
|
||||
upload.raise_for_status()
|
||||
|
||||
listed = requests.get(f"{base}/api/v1/files/list/{flow_id}", headers=headers, timeout=30)
|
||||
listed.raise_for_status()
|
||||
print(json.dumps({"upload": upload.json(), "list": listed.json()}))
|
||||
@ -0,0 +1,22 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/upload/{os.getenv('FLOW_ID', '')}"
|
||||
|
||||
headers = {
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
files = {
|
||||
"file": open(os.getenv("SAMPLE_IMAGE_FILE", "docs/docs/API-Reference/fixtures/sample-upload.png"), "rb"),
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, files=files)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
|
||||
for _f in files.values():
|
||||
if hasattr(_f, "close"):
|
||||
_f.close()
|
||||
Reference in New Issue
Block a user