_format_url() — langchain Function Reference
Architecture documentation for the _format_url() function in openapi.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD adfd5561_12c8_04fe_9054_a7f68ebc91f4["_format_url()"] a34d3b0d_246d_bf4f_cf5f_c38a4937926e["openapi.py"] adfd5561_12c8_04fe_9054_a7f68ebc91f4 -->|defined in| a34d3b0d_246d_bf4f_cf5f_c38a4937926e 174ab5ce_1945_87e8_8e93_22af84e01f0a["openapi_spec_to_openai_fn()"] 174ab5ce_1945_87e8_8e93_22af84e01f0a -->|calls| adfd5561_12c8_04fe_9054_a7f68ebc91f4 style adfd5561_12c8_04fe_9054_a7f68ebc91f4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/openai_functions/openapi.py lines 31–66
def _format_url(url: str, path_params: dict) -> str:
expected_path_param = re.findall(r"{(.*?)}", url)
new_params = {}
for param in expected_path_param:
clean_param = param.lstrip(".;").rstrip("*")
val = path_params[clean_param]
if isinstance(val, list):
if param[0] == ".":
sep = "." if param[-1] == "*" else ","
new_val = "." + sep.join(val)
elif param[0] == ";":
sep = f"{clean_param}=" if param[-1] == "*" else ","
new_val = f"{clean_param}=" + sep.join(val)
else:
new_val = ",".join(val)
elif isinstance(val, dict):
kv_sep = "=" if param[-1] == "*" else ","
kv_strs = [kv_sep.join((k, v)) for k, v in val.items()]
if param[0] == ".":
sep = "."
new_val = "."
elif param[0] == ";":
sep = ";"
new_val = ";"
else:
sep = ","
new_val = ""
new_val += sep.join(kv_strs)
elif param[0] == ".":
new_val = f".{val}"
elif param[0] == ";":
new_val = f";{clean_param}={val}"
else:
new_val = val
new_params[param] = new_val
return url.format(**new_params)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _format_url() do?
_format_url() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/openai_functions/openapi.py.
Where is _format_url() defined?
_format_url() is defined in libs/langchain/langchain_classic/chains/openai_functions/openapi.py at line 31.
What calls _format_url()?
_format_url() is called by 1 function(s): openapi_spec_to_openai_fn.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free