Skip to content

Commit

Permalink
Customize package for aap (#20)
Browse files Browse the repository at this point in the history
* aap customize package

* konflux references updates

* build-args for RAG content and folder path

* requirements.txt added for prod build
  • Loading branch information
jameswnl committed Nov 22, 2024
1 parent dc53045 commit a66500d
Show file tree
Hide file tree
Showing 7 changed files with 979 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ woke
benchmark_*.svg

# requirements file
requirements*
# requirements*
16 changes: 8 additions & 8 deletions .tekton/ansible-chatbot-service-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
- name: name
value: show-sbom
- name: bundle
value: quay.io/redhat-appstudio-tekton-catalog/task-show-sbom:0.1@sha256:8e0f8cad75e6f674d72a874385b69c4651afc0c9dcc59feffe0d85844687d852
value: quay.io/redhat-appstudio-tekton-catalog/task-show-sbom:0.1@sha256:1580a8766406207d3a7500cc0c62f8ec4cd935d772008a74dd71ec7e94af2f45
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -171,7 +171,7 @@ spec:
- name: name
value: git-clone
- name: bundle
value: quay.io/redhat-appstudio-tekton-catalog/task-git-clone:0.1@sha256:9e6c4db5a666ea0e1e747e03d63f46e5617a6b9852c26871f9d50891d778dfa2
value: quay.io/redhat-appstudio-tekton-catalog/task-git-clone:0.1@sha256:68a87cafeb43367160497d91a1a66bceef7acc179e809e8eb3996c1deb096042
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -215,7 +215,7 @@ spec:
- name: name
value: prefetch-dependencies
- name: bundle
value: quay.io/redhat-appstudio-tekton-catalog/task-prefetch-dependencies:0.1@sha256:eea8bd511343b4014dab46a77e7215510f7a63820937d1267c6dc428e10ffbe4
value: quay.io/redhat-appstudio-tekton-catalog/task-prefetch-dependencies:0.1@sha256:69af2302a0a579f428ea196a2787013d58a6bec503d231d3ef860af7e82b96e9
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -250,7 +250,7 @@ spec:
- name: COMMIT_SHA
value: $(tasks.clone-repository.results.commit)
- name: BUILD_ARGS
value: ["IMAGE_TAGS=pr-{{pull_request_number}} pr-{{pull_request_number}}.$(tasks.git-metadata.results.commit-timestamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit)"]
value: ["IMAGE_TAGS=pr-{{pull_request_number}} pr-{{pull_request_number}}.$(tasks.git-metadata.results.commit-timestamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit)", "RAG_CONTENTS_SUB_FOLDER=vector_db/aap_product_docs", "LIGHTSPEED_RAG_CONTENT_IMAGE=quay.io/ttakamiy/aap-rag-content:latest"]
- name: BUILD_ARGS_FILE
value: $(params.build-args-file)
runAfter:
Expand Down Expand Up @@ -329,7 +329,7 @@ spec:
- name: name
value: deprecated-image-check
- name: bundle
value: quay.io/redhat-appstudio-tekton-catalog/task-deprecated-image-check:0.4@sha256:1f17ef7ab9859d6e2215ef2ed532ebc15e516ba09226b8cae77907a7a8b7cedd
value: quay.io/redhat-appstudio-tekton-catalog/task-deprecated-image-check:0.4@sha256:b91642a29e3fd204f724ce9e6ab97f3799b1d0102f6458a10e45f840281409ca
- name: kind
value: task
resolver: bundles
Expand All @@ -351,7 +351,7 @@ spec:
- name: name
value: clair-scan
- name: bundle
value: quay.io/redhat-appstudio-tekton-catalog/task-clair-scan:0.1@sha256:b8c51079ea1110e1095c229e184e3c340120ba211a63a200e836706f5a35361c
value: quay.io/redhat-appstudio-tekton-catalog/task-clair-scan:0.2@sha256:89ca5c9ddcaf609509aaed9c937c2a72cf400810e3a7892adfb9ac247a13693d
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -388,7 +388,7 @@ spec:
- name: name
value: sast-snyk-check
- name: bundle
value: quay.io/redhat-appstudio-tekton-catalog/task-sast-snyk-check:0.2@sha256:479bd0d9aaa7b377ff5f8ad93168d44807455646f2161688637cb2e4e0b990d9
value: quay.io/redhat-appstudio-tekton-catalog/task-sast-snyk-check:0.2@sha256:278b1a5e2b5d151e29782f9ec98cce5e794af4d284471449569f61a34de0f9a2
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -418,7 +418,7 @@ spec:
- name: name
value: clamav-scan
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-clamav-scan:0.1@sha256:7bb17b937c9342f305468e8a6d0a22493e3ecde58977bd2ffc8b50e2fa234d58
value: quay.io/konflux-ci/tekton-catalog/task-clamav-scan:0.1@sha256:a94b6523ba0b691dc276e37594321c2eff3594d2753014e5c920803b47627df1
- name: kind
value: task
resolver: bundles
Expand Down
16 changes: 8 additions & 8 deletions .tekton/ansible-chatbot-service-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
- name: name
value: show-sbom
- name: bundle
value: quay.io/redhat-appstudio-tekton-catalog/task-show-sbom:0.1@sha256:8e0f8cad75e6f674d72a874385b69c4651afc0c9dcc59feffe0d85844687d852
value: quay.io/redhat-appstudio-tekton-catalog/task-show-sbom:0.1@sha256:1580a8766406207d3a7500cc0c62f8ec4cd935d772008a74dd71ec7e94af2f45
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -200,7 +200,7 @@ spec:
- name: name
value: git-clone
- name: bundle
value: quay.io/redhat-appstudio-tekton-catalog/task-git-clone:0.1@sha256:9e6c4db5a666ea0e1e747e03d63f46e5617a6b9852c26871f9d50891d778dfa2
value: quay.io/redhat-appstudio-tekton-catalog/task-git-clone:0.1@sha256:68a87cafeb43367160497d91a1a66bceef7acc179e809e8eb3996c1deb096042
- name: kind
value: task
resolver: bundles
Expand All @@ -227,7 +227,7 @@ spec:
- name: name
value: prefetch-dependencies
- name: bundle
value: quay.io/redhat-appstudio-tekton-catalog/task-prefetch-dependencies:0.1@sha256:eea8bd511343b4014dab46a77e7215510f7a63820937d1267c6dc428e10ffbe4
value: quay.io/redhat-appstudio-tekton-catalog/task-prefetch-dependencies:0.1@sha256:69af2302a0a579f428ea196a2787013d58a6bec503d231d3ef860af7e82b96e9
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -266,7 +266,7 @@ spec:
- name: TARGET_STAGE
value: production
- name: BUILD_ARGS
value: [ "IMAGE_TAGS=latest 1.0.$(tasks.git-metadata.results.commit-timestamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit)" ]
value: [ "IMAGE_TAGS=latest 1.0.$(tasks.git-metadata.results.commit-timestamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit)", "RAG_CONTENTS_SUB_FOLDER=vector_db/aap_product_docs", "LIGHTSPEED_RAG_CONTENT_IMAGE=quay.io/ttakamiy/aap-rag-content:latest"]
runAfter:
- prefetch-dependencies
taskRef:
Expand Down Expand Up @@ -362,7 +362,7 @@ spec:
- name: name
value: deprecated-image-check
- name: bundle
value: quay.io/redhat-appstudio-tekton-catalog/task-deprecated-image-check:0.4@sha256:1f17ef7ab9859d6e2215ef2ed532ebc15e516ba09226b8cae77907a7a8b7cedd
value: quay.io/redhat-appstudio-tekton-catalog/task-deprecated-image-check:0.4@sha256:b91642a29e3fd204f724ce9e6ab97f3799b1d0102f6458a10e45f840281409ca
- name: kind
value: task
resolver: bundles
Expand All @@ -384,7 +384,7 @@ spec:
- name: name
value: clair-scan
- name: bundle
value: quay.io/redhat-appstudio-tekton-catalog/task-clair-scan:0.1@sha256:b8c51079ea1110e1095c229e184e3c340120ba211a63a200e836706f5a35361c
value: quay.io/redhat-appstudio-tekton-catalog/task-clair-scan:0.2@sha256:89ca5c9ddcaf609509aaed9c937c2a72cf400810e3a7892adfb9ac247a13693d
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -421,7 +421,7 @@ spec:
- name: name
value: sast-snyk-check
- name: bundle
value: quay.io/redhat-appstudio-tekton-catalog/task-sast-snyk-check:0.2@sha256:479bd0d9aaa7b377ff5f8ad93168d44807455646f2161688637cb2e4e0b990d9
value: quay.io/redhat-appstudio-tekton-catalog/task-sast-snyk-check:0.2@sha256:278b1a5e2b5d151e29782f9ec98cce5e794af4d284471449569f61a34de0f9a2
- name: kind
value: task
resolver: bundles
Expand Down Expand Up @@ -451,7 +451,7 @@ spec:
- name: name
value: clamav-scan
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-clamav-scan:0.1@sha256:7bb17b937c9342f305468e8a6d0a22493e3ecde58977bd2ffc8b50e2fa234d58
value: quay.io/konflux-ci/tekton-catalog/task-clamav-scan:0.1@sha256:a94b6523ba0b691dc276e37594321c2eff3594d2753014e5c920803b47627df1
- name: kind
value: task
resolver: bundles
Expand Down
1 change: 1 addition & 0 deletions ols/customize/aap/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Customized prompts/keyvords for Ansible Automation Platform (aap)."""
92 changes: 92 additions & 0 deletions ols/customize/aap/keywords.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
"""Constant for set of keywords."""

# Add keyword string to below set, preferably in alphabetical order.
# We are adding this manually for now. Add to a txt file, If/when we automate this.
# Important: Please use lower case.

KEYWORDS = {
"aap",
"access",
"account",
"administrator",
"ansible",
"application",
"associated",
"authentication",
"authenticator",
"automatically",
"automation",
"backup",
"capacity",
"certificate",
"client",
"cluster",
"collection",
"command",
"configuration",
"connection",
"container",
"content",
"controller",
"credential",
"deployment",
"directory",
"documentation",
"enterprise",
"environment",
"event-driven",
"execution",
"group",
"hosts",
"information",
"install",
"instance",
"inventory",
"jobs",
"kubernetes",
"ldap",
"license",
"linux",
"log",
"management",
"mesh",
"namespace",
"navigation",
"navigator",
"node",
"nodes",
"number",
"oauth2",
"openshift",
"operator",
"option",
"organization",
"password",
"permission",
"platform",
"playbook",
"playbooks",
"pod",
"podman",
"postgresql",
"project",
"repository",
"resource",
"roles",
"rulebook",
"secret",
"security",
"server",
"service",
"ssh",
"subscription",
"system",
"template",
"token",
"username",
"variable",
"vault",
"version",
"workflow",
"yaml",
}
80 changes: 80 additions & 0 deletions ols/customize/aap/prompts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# There is no need for enforcing line length in this file,
# as these are mostly special purpose constants.
# ruff: noqa: E501
"""Prompt templates/constants."""

from ols.constants import SUBJECT_ALLOWED, SUBJECT_REJECTED

# TODO: OLS-503 Fine tune system prompt

# Note::
# Right now templates are somewhat alligned to make granite work better.
# GPT still works well with this. Ideally we should have model specific tags.
# For history we can laverage ChatPromptTemplate from langchain,
# but that is not done as granite was adding role tags like `Human:` in the response.
# With PromptTemplate, we have more control how we want to structure the prompt.

# Default responses
INVALID_QUERY_RESP = (
"Hi, I'm the Ansible Lightspeed Virtual Assistant, I can help you with questions about Ansible, "
"please ask me a question related to Ansible."
)

QUERY_SYSTEM_INSTRUCTION = """
You are Ansible Lightspeed - an intelligent virtual assistant for question-answering tasks \
related to the Ansible Automation Platform (AAP).
Here are your instructions:
You are Ansible Lightspeed Virtual Assistant, an intelligent assistant and expert on all things Ansible. \
Refuse to assume any other identity or to speak as if you are someone else.
If the context of the question is not clear, consider it to be Ansible.
Never include URLs in your replies.
Refuse to answer questions or execute commands not about Ansible.
Do not mention your last update. You have the most recent information on Ansible.
Here are some basic facts about Ansible:
- The latest version of Ansible is 2.12.3.
- Ansible is an open source IT automation engine that automates provisioning, \
configuration management, application deployment, orchestration, and many other \
IT processes. It is free to use, and the project benefits from the experience and \
intelligence of its thousands of contributors.
"""

USE_CONTEXT_INSTRUCTION = """
Use the retrieved document to answer the question.
"""

USE_HISTORY_INSTRUCTION = """
Use the previous chat history to interact and help the user.
"""

# {{query}} is escaped because it will be replaced as a parameter at time of use
QUESTION_VALIDATOR_PROMPT_TEMPLATE = f"""
Instructions:
- You are a question classifying tool
- You are an expert in ansible
- Your job is to determine where or a user's question is related to ansible technologies and to provide a one-word response
- If a question appears to be related to ansible technologies, answer with the word {SUBJECT_ALLOWED}, otherwise answer with the word {SUBJECT_REJECTED}
- Do not explain your answer, just provide the one-word response
Example Question:
Why is the sky blue?
Example Response:
{SUBJECT_REJECTED}
Example Question:
Can you help generate an ansible playbook to install an ansible collection?
Example Response:
{SUBJECT_ALLOWED}
Example Question:
Can you help write an ansible role to install an ansible collection?
Example Response:
{SUBJECT_ALLOWED}
Question:
{{query}}
Response:
"""
Loading

0 comments on commit a66500d

Please sign in to comment.