mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-24 07:34:10 +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,27 @@
|
||||
import os
|
||||
|
||||
from openai import OpenAI
|
||||
|
||||
base = (os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "")).rstrip("/")
|
||||
api_key = os.environ.get("LANGFLOW_API_KEY", "")
|
||||
flow_id = os.environ.get("FLOW_ID", "")
|
||||
|
||||
client = OpenAI(
|
||||
base_url=f"{base}/api/v1/",
|
||||
default_headers={"x-api-key": api_key},
|
||||
api_key="dummy-api-key", # Required by OpenAI SDK but not used by Langflow
|
||||
)
|
||||
|
||||
try:
|
||||
response = client.responses.create(
|
||||
model=flow_id,
|
||||
input="There is an event that happens on the second wednesday of every month. What are the event dates in 2026?",
|
||||
)
|
||||
except Exception as exc:
|
||||
# Empty bootstrap flows return an error body; use a flow with ChatInput + ChatOutput in the UI.
|
||||
print(exc)
|
||||
else:
|
||||
try:
|
||||
print(response.output_text)
|
||||
except Exception:
|
||||
print(response)
|
||||
@ -0,0 +1,29 @@
|
||||
# Continuation requests use the same endpoint; add `previous_response_id` from a prior
|
||||
# response's `id` field. The bootstrap flow is empty; use a Playground flow with ChatInput +
|
||||
# ChatOutput for a full run. Same first message as continue-conversations-with-response-and-session-ids.py.
|
||||
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "")
|
||||
flow_id = os.environ.get("FLOW_ID", "")
|
||||
api_key = os.environ.get("LANGFLOW_API_KEY", "")
|
||||
|
||||
url = f"{base}/api/v1/responses"
|
||||
|
||||
headers = {
|
||||
"x-api-key": api_key,
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
payload = {
|
||||
"model": flow_id,
|
||||
"input": "Hello, my name is Alice",
|
||||
"stream": False,
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, json=payload, timeout=120)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,28 @@
|
||||
# Same pattern as continue-conversations-with-response-and-session-ids-2.py; you can pass
|
||||
# `previous_response_id` from the prior turn (or a session id your app stores).
|
||||
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "")
|
||||
flow_id = os.environ.get("FLOW_ID", "")
|
||||
api_key = os.environ.get("LANGFLOW_API_KEY", "")
|
||||
|
||||
url = f"{base}/api/v1/responses"
|
||||
|
||||
headers = {
|
||||
"x-api-key": api_key,
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
payload = {
|
||||
"model": flow_id,
|
||||
"input": "Hello, my name is Alice",
|
||||
"stream": False,
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, json=payload, timeout=120)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,25 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "")
|
||||
flow_id = os.environ.get("FLOW_ID", "")
|
||||
api_key = os.environ.get("LANGFLOW_API_KEY", "")
|
||||
|
||||
url = f"{base}/api/v1/responses"
|
||||
|
||||
headers = {
|
||||
"x-api-key": api_key,
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
payload = {
|
||||
"model": flow_id,
|
||||
"input": "Hello, my name is Alice",
|
||||
"stream": False,
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, json=payload, timeout=120)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,17 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/api/v1/responses"
|
||||
|
||||
headers = {
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
payload = {"model": "$YOUR_FLOW_ID", "input": "Hello, how are you?", "stream": False}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, json=payload)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,17 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/api/v1/responses"
|
||||
|
||||
headers = {
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
payload = {"model": "$FLOW_ID", "input": "Tell me a story about a robot", "stream": True}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, json=payload)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,20 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/api/v1/responses"
|
||||
|
||||
headers = {
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
"Content-Type": "application/json",
|
||||
"X-LANGFLOW-GLOBAL-VAR-OPENAI_API_KEY": "sk-...",
|
||||
"X-LANGFLOW-GLOBAL-VAR-USER_ID": "user123",
|
||||
"X-LANGFLOW-GLOBAL-VAR-ENVIRONMENT": "production",
|
||||
}
|
||||
|
||||
payload = {"model": "your-flow-id", "input": "Hello"}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, json=payload)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,26 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "")
|
||||
flow_id = os.environ.get("FLOW_ID", "")
|
||||
api_key = os.environ.get("LANGFLOW_API_KEY", "")
|
||||
|
||||
url = f"{base}/api/v1/responses"
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"x-api-key": api_key,
|
||||
}
|
||||
|
||||
payload = {
|
||||
"model": flow_id,
|
||||
"input": "Calculate 23 * 15 and show me the result",
|
||||
"stream": False,
|
||||
"include": ["tool_call.results"],
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, json=payload, timeout=120)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,17 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/api/v1/responses"
|
||||
|
||||
headers = {
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
payload = {"model": "FLOW_ID", "input": "Explain quantum computing in simple terms", "stream": False}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, json=payload)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
Reference in New Issue
Block a user