Skip to content

Commit

Permalink
feat: cache output in memory
Browse files Browse the repository at this point in the history
  • Loading branch information
phanhongan committed Nov 15, 2024
1 parent 5a019a6 commit 2868bee
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions examples/llamarine/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,24 @@ def main(use_domain_lm: bool = False):
with st.spinner(text='_SOLVING..._'):
logger.level('DEBUG')

st.session_state.agent_solutions[st.session_state.typed_problem]: str = \
get_or_create_agent(use_domain_lm).solve(
problem=st.session_state.typed_problem, allow_reject=True)

if (solution := st.session_state.agent_solutions[st.session_state.typed_problem]):
if use_domain_lm:
solution = OpenAILM.from_defaults().get_response(
prompt=f"""Please respond the following text, with making sure there is a conclusion which is the main action item at the end of the response.
{solution}
""",
history=[
{"role": "system", "content": LLAMARINE_SYSTEM_PROMPT},
{"role": "user", "content": LLAMARINE_USER_PROMPT},
]
)

st.markdown(body=solution)
if not st.session_state.agent_solutions[st.session_state.typed_problem]:
st.session_state.agent_solutions[st.session_state.typed_problem]: str = \
get_or_create_agent(use_domain_lm).solve(
problem=st.session_state.typed_problem, allow_reject=True)

solution = st.session_state.agent_solutions[st.session_state.typed_problem]
if use_domain_lm:
solution = OpenAILM.from_defaults().get_response(
prompt=f"""Please respond the following text, with making sure there is a conclusion which is the main action item at the end of the response.
{solution}
""",
history=[
{"role": "system", "content": LLAMARINE_SYSTEM_PROMPT},
{"role": "user", "content": LLAMARINE_USER_PROMPT},
]
)

st.markdown(body=solution)


if __name__ == '__main__':
Expand Down

0 comments on commit 2868bee

Please sign in to comment.