MCPcopy Create free account
hub / github.com/DVampire/FinAgent / text_replace

Function text_replace

finagent/prompt/helper.py:20–41  ·  view source on GitHub ↗
(text: str, params: Dict[str, Any])

Source from the content-addressed store, hash-verified

18 return doc
19
20def text_replace(text: str, params: Dict[str, Any]):
21 keys = params.keys()
22
23 # find all keys in text
24 exiting_keys = []
25 for key in keys:
26 if f"$${key}$$" in text:
27 exiting_keys.append(key)
28
29 # get all values of exiting keys
30 exiting_values = [params[key] for key in exiting_keys]
31
32 # if there is None in exiting_values, return None
33 if None in exiting_values:
34 return None
35 else:
36 for key in exiting_keys:
37 if isinstance(params[key], list) or isinstance(params[key], dict):
38 text = text.replace(f"$${key}$$", json.dumps(params[key], indent=4))
39 else:
40 text = text.replace(f"$${key}$$", str(params[key]))
41 return text
42
43
44def content_replace(content: str):

Callers 1

generate_prompt_htmlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected