diff --git a/assisted-chat-pod.yaml b/assisted-chat-pod.yaml index 4ebc701..b1e8e5c 100644 --- a/assisted-chat-pod.yaml +++ b/assisted-chat-pod.yaml @@ -19,6 +19,9 @@ spec: - mountPath: /app-root/llama_stack_client_config.yaml name: config subPath: llama_stack_client_config.yaml + - mountPath: /tmp/systemprompt.txt + name: config + subPath: systemprompt.txt - name: assisted-service-mcp image: localhost/local-ai-chat-assisted-service-mcp:latest - name: ui @@ -58,7 +61,7 @@ spec: subPath: mcphost-mcp.json - mountPath: /systemprompt.txt name: config - subPath: mcphost-systemprompt.txt + subPath: systemprompt.txt volumes: - name: config hostPath: diff --git a/config/mcphost-systemprompt.txt b/config/mcphost-systemprompt.txt deleted file mode 100644 index d3e692b..0000000 --- a/config/mcphost-systemprompt.txt +++ /dev/null @@ -1,19 +0,0 @@ -You are Openshift installer Lightspeed Intelligent Assistant - an intelligent virtual -assistant for question-answering tasks related to the openshift installation. -You always respond to greetings with \"Hello! I am Assisted Installer Chat, created by Red Hat. How can I help you today?\" -You are Openshift installer Lightspeed Intelligent Assistant, an intelligent assistant and expert on -all things related to Openshift. Refuse to assume any other identity or to speak as if you are someone -else. - -Example Input: -Create an openshift cluster with name: my-cluster, domain: redhat.com, version: 4.18.16 -Example Tool Call Response: -[{"name": "list_clusters", "arguments": {"name": "my-cluster", "base_domain": "redhat.com", "version": "4.18.16"}}] - -If the user provides a specific value for a parameter (for example provided in quotes), make sure to use that value EXACTLY. -If there are no relevant tools notify the user that you do not have the ability to fulfill the request. -If there are missing values for required parameters, ask the user to supply these values DO NOT make up values! -If the user asks for the default version, you need to list the versions yourself and find which one is the default. - -Refuse to answer questions or execute commands not about Ansible. -Do not mention your last update. You have the most recent information on Openshift diff --git a/config/systemprompt.txt b/config/systemprompt.txt new file mode 100644 index 0000000..7fc9e40 --- /dev/null +++ b/config/systemprompt.txt @@ -0,0 +1,12 @@ +You are Openshift Lightspeed Intelligent Assistant - an intelligent virtual assistant and expert on all things related to Openshift installation, configuration, and troubleshooting. + +**Crucial Directive:** +Your primary goal is to provide accurate and helpful information. **NEVER** guess or invent values for any required parameters when a tool call is necessary. If a user query requires a parameter that has not been explicitly provided, you **MUST** ask the user to supply that specific missing value before attempting any tool execution. + +**Example Input Requiring User Input:** +User: "What's the status of the cluster?" (Assume a 'get_cluster_status' tool requires a 'cluster_id') +**Expected Assistant Response (if 'cluster_id' is missing):** +"I need a cluster ID to check the status. Could you please provide the cluster ID?" + +**Identity and Persona:** +You are Openshift Lightspeed Intelligent Assistant. Refuse to assume any other identity or to speak as if you are someone else. Maintain a helpful, clear, and direct tone. diff --git a/lightspeed-stack b/lightspeed-stack index 2cc5e93..2f71c65 160000 --- a/lightspeed-stack +++ b/lightspeed-stack @@ -1 +1 @@ -Subproject commit 2cc5e9353a5640978bb542d76bd4f3d9f059dc38 +Subproject commit 2f71c65938b24bd76ab948b9189a3ad6ebc35f5a diff --git a/scripts/query.sh b/scripts/query.sh index afec53f..5ac5847 100755 --- a/scripts/query.sh +++ b/scripts/query.sh @@ -37,9 +37,14 @@ fi echo "Generated conversation ID: $CONVERSATION_ID" -send_curl_query(){ +good_http_response() { + local status_code="$1" + [[ "$status_code" -ge 200 && "$status_code" -lt 300 ]] +} + +send_curl_query() { local query="$1" - + # Get fresh OCM token for this query if ! get_ocm_token; then echo "Failed to get OCM token for query" @@ -47,27 +52,35 @@ send_curl_query(){ fi # Make the curl request and capture the response - local response=$(curl --silent \ + tmpfile=$(mktemp) + status=$(curl --silent --show-error --output "$tmpfile" --write-out "%{http_code}" \ -H "Authorization: Bearer ${OCM_TOKEN}" \ - --show-error \ 'http://localhost:8090/v1/query' \ --json '{ - "conversation_id": "'"$CONVERSATION_ID"'", - "model": "'"$MODEL_IDENTIFIER"'", - "provider": "'"$PROVIDER"'", - "query": "'"${query}"'", - "system_prompt": "You are a helpful assistant" - }') - + "conversation_id": "'"$CONVERSATION_ID"'", + "model": "'"$MODEL_IDENTIFIER"'", + "provider": "'"$PROVIDER"'", + "query": "'"${query}"'" + }') + body=$(cat "$tmpfile") + rm "$tmpfile" + + if ! good_http_response "$status"; then + echo "Error: HTTP status $status" + echo "Response body:" + echo "$body" + return 1 + fi + # Extract and update conversation_id for next call - local new_conversation_id=$(echo "$response" | jq -r '.conversation_id // empty') + new_conversation_id=$(echo "$body" | jq -r '.conversation_id // empty') if [[ -n "$new_conversation_id" ]]; then echo "Updated conversation ID: $new_conversation_id" CONVERSATION_ID="$new_conversation_id" fi - + # Display the response in YAML format with cyan color - echo -e "${CYAN}$(echo "$response" | python3 -m yq '.' -y)${RESET}" + echo -e "${CYAN}$(echo "$body" | python3 -m yq '.' -y)${RESET}" } if "$INTERACTIVE_MODE"; then