MCPcopy Create free account
hub / github.com/apache/burr / write

Function write

examples/ray/application.py:52–81  ·  view source on GitHub ↗

Writes a draft of a poem.

(state: State)

Source from the content-addressed store, hash-verified

50 writes=["current_draft", "draft_history", "num_drafts"],
51)
52def write(state: State) -> Tuple[dict, State]:
53 """Writes a draft of a poem."""
54 poem_subject = state["poem_subject"]
55 poem_type = state["poem_type"]
56 current_draft = state.get("current_draft")
57 feedback = state.get("feedback")
58
59 parts = [
60 f'You are an AI poet. Create a {poem_type} poem on the following subject: "{poem_subject}". '
61 "It is absolutely imperative that you respond with only the poem and no other text."
62 ]
63
64 if current_draft:
65 parts.append(f'Here is the current draft of the poem: "{current_draft}".')
66
67 if feedback:
68 parts.append(f'Please incorporate the following feedback: "{feedback}".')
69
70 parts.append(
71 f"Ensure the poem is creative, adheres to the style of a {poem_type}, and improves upon the previous draft."
72 )
73
74 prompt = "\n".join(parts)
75
76 draft = _query_llm(prompt)
77
78 return {"draft": draft}, state.update(
79 current_draft=draft,
80 draft_history=state.get("draft_history", []) + [draft],
81 ).increment(num_drafts=1)
82
83
84@action(reads=["current_draft", "poem_type", "poem_subject"], writes=["feedback"])

Callers

nothing calls this directly

Calls 5

incrementMethod · 0.80
_query_llmFunction · 0.70
getMethod · 0.45
appendMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected