-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
94 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# vim:fenc=utf-8 | ||
|
||
# SPDX-FileCopyrightText: 2023 imotai <[email protected]> | ||
# SPDX-FileContributor: imotai | ||
# | ||
# SPDX-License-Identifier: Elastic-2.0 | ||
|
||
""" | ||
""" | ||
|
||
|
||
# import the agent memory | ||
from og_proto.memory_pb2 import AgentMemory | ||
from jinja2 import Environment | ||
from jinja2.loaders import PackageLoader | ||
|
||
env = Environment(loader=PackageLoader("og_memory", "template")) | ||
context_tpl = env.get_template("agent.jinja") | ||
|
||
def agent_memory_to_context(memory: AgentMemory): | ||
""" | ||
Convert the agent memory to context | ||
:param memory : AgentMemory | ||
:return: string context for llm | ||
""" | ||
return context_tpl.render(prompt=memory.instruction, guides=memory.guide_memory) | ||
|
||
|
||
|
Empty file.
15 changes: 8 additions & 7 deletions
15
...src/og_memory/template/agent.openai.jinja → memory/src/og_memory/template/agent.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
{#the role description#} | ||
{{prompt.role}} | ||
|
||
{#the rule list#} | ||
{%if prompt.rules%} | ||
You must follow the below rules | ||
Follow the rules | ||
{% for rule in prompt.rules if rule%} | ||
{{loop.index}}.{{rule}} | ||
{% endfor%} | ||
{% endif %} | ||
|
||
{%if prompt.actions%} | ||
You can use the following actions to help you finishing your task | ||
Use the following actions to help you finishing your task | ||
{% for action in prompt.actions if action%} | ||
{{loop.index}}.{{action.name}}: {{action.desc}} | ||
{% endfor%} | ||
{% endif %} | ||
|
||
{%if guides%} | ||
Here are the instructions for the tools and libraries you recently used. | ||
|
||
The instructions for the tools and libraries you recently used. | ||
{% for guide in guides if guide%} | ||
{{loop.index}}.{{guide.name}} | ||
{{guide.what_it_can_do}} | ||
{{guide.how_to_use}} | ||
{% endfor%} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# vim:fenc=utf-8 | ||
|
||
# SPDX-FileCopyrightText: 2023 imotai <[email protected]> | ||
# SPDX-FileContributor: imotai | ||
# | ||
# SPDX-License-Identifier: Elastic-2.0 | ||
|
||
""" | ||
""" | ||
from og_memory.memory import agent_memory_to_context | ||
from og_proto.memory_pb2 import AgentMemory, ChatMessage, GuideMemory, Feedback | ||
from og_proto.prompt_pb2 import AgentPrompt, ActionDesc | ||
# defina a logger variable | ||
import logging | ||
logger = logging.getLogger(__name__) | ||
|
||
def test_agent_memory_to_context_smoke_test(): | ||
""" | ||
test the gent_memory_to_contex for smoke test | ||
""" | ||
action = ActionDesc(name="execute_python_code", desc="run python code") | ||
rules = ["To complete the goal, write a plan and execute it step-by-step, limiting the number of steps to five. the following are examples"] | ||
prompt = AgentPrompt(actions=[action], rules=rules, | ||
role="You are the QA engineer", | ||
role_name="Kitty", output_format="") | ||
agent_memory = AgentMemory(instruction=prompt, user_id = "1", user_name="tai", guide_memory=[], chat_memory=[], | ||
memory_id="2") | ||
context = agent_memory_to_context(agent_memory) | ||
logger.info(context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -572,6 +572,7 @@ def start_octogen_for_azure_openai( | |
return False | ||
|
||
|
||
|
||
def start_octogen_for_codellama( | ||
live, | ||
segments, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters