vania-janet/multiturn-rag-retrieval-data huggingface dataset:
This configuration builds from the public Git repo https://github.com/IBM/CodeEngine, uses the dockerfile strategy and medium build size, and stores the image to us.icr.io/mynamespace/codeengine-helloworld by using the image registry secret that is defined in myregistry.

ibmcloud ce build create --name helloworld-build --image us.icr.io/mynamespace/codeengine-helloworld --registry-secret myregistry --source https://github.com/IBM/CodeEngine --commit main --context-dir /hello --strategy dockerfile --size medium
2. Run the build. This example runs a build that is called helloworld-build-run and uses the helloworld-build build configuration.

ibmcloud ce buildrun submit --build helloworld-build --name helloworld-build-run

The following output displays the details of the build run by using the [ibmcloud ce buildrun get](https://cloud.ibm.com/docs/codeengine?topic=codeengine-clicli-buildrun-get) command.

Example output

Getting build run 'helloworld-build-run'...
[...]
OK

Name: helloworld-build-run
ID: abcdefgh-abcd-abcd-abcd-1a2b3c4d5e6f
Project Name: myproject
Project ID: 01234567-abcd-abcd-abcd-abcdabcd1111
Age: 21m
Created: 2021-09-30T14:50:13-05:00

Summary: Succeeded
Status: Succeeded
Reason: All Steps have completed executing

Image: us.icr.io/mynamespace/codeengine-helloworld

For more information about creating a build configuration with the CLI, see [create a build](https://cloud.ibm.com/docs/codeengine?topic=codeengine-build-imagebuild-create-cli).
3.
You can create an action that includes multiple Go packages. Each package must include a go.mod file.

.
├── go.mod
├── hello
│ ├── go.mod
│ └── hello.go
└── main.go



1. Create the following example files as shown in the following examples.

main.go

package main

import (
"fmt"
"hello"
)

func Main(args map[string]interface{}) map[string]interface{} {
fmt.Println("Main")
return hello.Hello(args)
}

go.mod

module action

go 1.19

replace hello => ./hello

require hello v0.0.0

hello/hello.go

package hello

import (
"fmt"
)

func Hello(args map[string]interface{}) map[string]interface{} {
msg := make(map[string]interface{})
greetings := "world"
name, ok := args["name"].(string)
if ok {
greetings = name
}
msg["msg"] = "Hello, " + greetings
fmt.Printf("Hello, %sn", greetings)
return msg
}
Show more

hello/go.mod

module hello

go 1.19
2. Compress the source code files into a compressed file that is called src.zip.

zip -r src.zip main.go go.mod hello/hello.go hello/go.mod

This command compresses the files main.go go.mod hello/hello.go hello/go.mod into src.zip. For more information about the zip command, use man zip.

If you are pre-compiling your code you might have to generate a go sum by running go mod tidy and adding it to your zip
3.
"host": "172.17.0.1",
"user-agent": "curl/7.43.0"
},
"__ow_path": ""
}
}

c. You can also test the web action by using form data. You can test the web action by using one of the following methods.{: #form_data} * Running the following cURL command.

 {: pre}
curl https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.json -d "name":"Jane"

* Running the following wget command.

 {: pre}
wget https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.json -d "name":"Jane"


Example output

{
"response": {
"name": "Jane",
"__ow_method": "post",
"__ow_headers": {
"accept": "/",
"connection": "close",
"content-length": "10",
"content-type": "application/x-www-form-urlencoded",
"host": "172.17.0.1",
"user-agent": "curl/7.43.0"
},
"__ow_path": ""
}
}

d. You can specify a JSON object by running the following command. You can test the web action by using one of the following methods.

* Running the following cURL command.

 {: pre}
curl https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.json -H 'Content-Type: application/json' -d '{"name":"Jane"}'

* Running the following wget command.

 {: pre}
* [Create and work with a project](https://cloud.ibm.com/docs/codeengine?topic=codeengine-manage-project).
* [Create a registry secret so you can save your image](https://cloud.ibm.com/docs/codeengine?topic=codeengine-add-registry).





1. Create a build configuration to build an image from a public Git repo and specify the location of the image registry for the build output with a registry secret. With the build create command, specify the --image option to provide the location of the image registry, and specify the --registry-secret option to access the registry. For example, the following command creates a build configuration that is called helloworld-build2 that builds from the public Git repo https://github.com/IBM/CodeEngine, and stores the image to us.icr.io/mynamespace/codeengine-helloworld by using the myregistry registry secret. In this example, the command uses the default dockerfile strategy, and the default medium build size. Because the branch name of the repository is not specified with the --commit option, Code Engine automatically uses the default branch of the specified repository, which is main for this Git repo.

If you are using the --strategy option with the value of dockerfile, then ensure the --dockerfile option is correctly set to the name of the dockerfile. The default value for the --strategy option is Dockerfile.

ibmcloud ce build create --name helloworld-build2 --image us.icr.io/mynamespace/codeengine-helloworld --registry-secret myregistry --source https://github.com/IBM/CodeEngine --context-dir /hello

Example output

Creating build helloworld-build2...
OK

The following table summarizes the options that are used with the build create command in this example.
View details about the mydatabasecm configmap by using the configmap get command.

ibmcloud ce configmap get -n mydatabasecm

Example output

Getting configmap 'mydatabasecm'...
OK

Name: mydatabasecm
ID: abcdefgh-abcd-abcd-abcd-1a2b3c4d5e6f
Project Name: myproject
Project ID: 01234567-abcd-abcd-abcd-abcdabcd1111
Age: 16s
Created: 2020-10-14 13:31:19 -0400 EDT

Data:
---
name: myname
url: myurl
3. Set an environment variable on a job to reference the url key in the mydatabasecm configmap. Use the --env-from-configmap NAME:KEY_A,KEY_B option where NAME:KEY_A specifies to reference the KEY_A of the configmap.

ibmcloud ce job create --name keydemo --image busybox --command env --env-from-configmap mydatabasecm:url
4. Run a job that uses the keydemo job.

ibmcloud ce jobrun submit --name keydemo1 --job keydemo
5. Display the logs of the job run by using the [ibmcloud ce jobrun logs](https://cloud.ibm.com/docs/codeengine?topic=codeengine-clicli-jobrun-logs) command. You can display logs of all the instances of a job run or display logs of a specific instance of a job run. To display the logs of a specific instance of the job run, use the --instance option with the jobrun logs command. If needed, use the jobrun get --name keydemo1 command to display details of this job run, including the instances of the job run.
Submitting build run 'helloworld-buildrun'...
Creating image 'private.us.icr.io/ce--27fe9-glxo4k7nj7d/buildrun-helloworld-buildrun'...
Run 'ibmcloud ce buildrun get -n helloworld-buildrun' to check the build run status.
OK

The following table summarizes the options that are used with the buildrun submit command in this example. For more information about the command and its options, see the [ibmcloud ce buildrun submit](https://cloud.ibm.com/docs/codeengine?topic=codeengine-clicli-buildrun-submit) command.



Table 1. Command description

 Option Description 

 --name The name of the build run. Use a name that is unique within the project.<br><br><br><br> * The name must begin and end with a lowercase letter.<br> * The name must be 63 characters or fewer and can contain lowercase alphanumeric characters and hyphens (-).<br><br><br> 
 --source The URL of the Git repository or the path to the local source that contains your source code; for example, https://github.com/IBM/CodeEngine. 
 --context-dir The directory in the repository that contains the buildpacks file or the Dockerfile. Specify this value if your buildpacks file or Dockerfile is contained in a subdirectory. 



2. Use the buildrun get command to check the status of your build run.

ibmcloud ce buildrun get --name helloworld-buildrun

Example output

Notice the generated name for the image and that the name of the automatically created registry secret is of the format, ce-auto-icr-private-<region>.

Getting build 'helloworld-buildrun'
For troubleshooting information visit: https://cloud.ibm.com/docs/codeengine?topic=codeengine-troubleshoot-build.
Commit Branch: main
Commit SHA: 946dd18f6e5a5474336786bc28d7dda93aec49c1
Commit Author: COMMIT_AUTHOR
Image Digest: sha256:39c4a87bc43102c2ee88562072c57c135b8dcc5cc4a1104e1d782fe3acc5d5b6
Image: private.us.icr.io/ce--e97a8-odof2whblw5/build-helloworld-buildrun-private
Registry Secret: ce-auto-icr-private-us-south
Build Strategy: buildpacks-v3-medium
Timeout: 10m0s
Source: git@github.com:myprivaterepo/builds.git
Context Directory: /hello
Repo Secret: myrepossh







 Running a single build with the CLI (with private repo source and and user-provided access to registry) 

In this user-provided access scenario, Code Engine builds an image from your private repository source with a Git repository secret that you provide, and then uploads the image to your container registry with the registry access that you provide with a single build command.

Before you begin



* [Set up your Code Engine CLI environment](https://cloud.ibm.com/docs/codeengine?topic=codeengine-install-cli).
* [Create and work with a project](https://cloud.ibm.com/docs/codeengine?topic=codeengine-manage-project).
* [Create an SSH secret to access your source](https://cloud.ibm.com/docs/codeengine?topic=codeengine-code-repositories).
* [Create a registry secret so you can save your image](https://cloud.ibm.com/docs/codeengine?topic=codeengine-add-registry).





1.
curl -X POST -H "Authorization: Bearer $API_BEARER_TOKEN" -H 'Content-type: application/json' -d '{"selector":{"country":{"$eq": "US"}},"limit":5,"bookmark":"g1AAAAA-eJzLYWBgYMpgSmHgKy5JLCrJTq2MT8lPzkzJBYqzmxiYWJiZGYGkOWDSyBJZAPCBD58"}' "$SERVICE_URL/cities/_find"
{
"docs":
{"_id":"4049979","_rev":"1-1fa2591477c774a07c230571568aeb66","name":"Birmingham","latitude":33.52066,"longitude":-86.80249,"country":"US","population":212237,"timezone":"America/Chicago"},
{"_id":"4054378","_rev":"1-a750085697685e7bc0e49d103d2de59d","name":"Center Point","latitude":33.64566,"longitude":-86.6836,"country":"US","population":16921,"timezone":"America/Chicago"},
{"_id":"4058219","_rev":"1-9b4eb183c9cdf57c19be660ec600330c","name":"Daphne","latitude":30.60353,"longitude":-87.9036,"country":"US","population":21570,"timezone":"America/Chicago"},
{: pre}
curl https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.json

* Running the following wget command.

 {: pre}
wget https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.json


Example output

{
"response": {
"__ow_method": "get",
"__ow_headers": {
"accept": "/",
"connection": "close",
"host": "172.17.0.1",
"user-agent": "curl/7.43.0"
},
"__ow_path": ""
}
}

b. Test the action by using a query parameter. You can test the action by either:

* Running the following cURL command.

 {: pre}
curl https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.json?name=Jane

* Running the following wget command.

 {: pre}
wget https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.json?name=Jane


Example output

{
"response": {
"name": "Jane",
"__ow_method": "get",
"__ow_headers": {
"accept": "/",
"connection": "close",
"host": "172.17.0.1",
"user-agent": "curl/7.43.0"
},
"__ow_path": ""
}
}

c. You can also test the web action by using form data. You can test the web action by using one of the following methods.{: #form_data} * Running the following cURL command.
* The sample readme file guidance for curling your OSB endpoints: [https://github.com/IBM/sample-resource-service-brokers/blob/master/README.md](https://github.com/IBM/sample-resource-service-brokers/blob/master/README.md).
* The Open Service Broker Reference App guidance for testing your broker: [Testing the broker](https://github.com/IBM-Cloud/onboarding-osbtesting-the-broker)





 Example curl request 

Use the following example to test your brokers curl response:

curl -X PUT https://<sample-service-broker>/v2/service_instances/<encoded-resource-crn> -u '<your broker user>:<your broker password>' -H 'content-type: application/json' -d '{ "context": {"platform": "ibmcloud", "account_id": "34ff5928-c3c7-4d46-bbf6-1a5628c325d1", "resource_group_crn": "crn:v1:bluemix:public:resource-controller::a/003e9bc3993aec710d30a5a719e57a80::resource-group:b4570a825f7f4d57aa54e8e1d9507926", "crn": "<resource-crn>", "target_crn": "<target_crn>"}, "service_id": "a07f025c-90db-4652-afd1-cf4adfac93c8", "plan_id": "fe442cec-2eef-41fe-9f92-58d6c094584f"}'
curl -X POST -H "Content-Type: application/json" -H "Authorization: IBM IAM TOKEN" --data "$(echo $PAYLOAD)" https://api.cis.cloud.ibm.com/v1/<crn>/zones/<zoneid>/graphql
Show more

The results are returned in JSON, so piping the output to jq makes them easier to read. For example:

curl -X POST -H "Content-Type: application/json" --data "$(echo $PAYLOAD)" https://api.cis.cloud.ibm.com/v1/<crn>/zones/<zoneid>/graphql | jq .
{
"data": {
"viewer": {
"zones": [
{
"firewallEventsAdaptive":
{
"action": "log",
"clientAsn": "5089",
"clientCountryName": "GB",
"clientIP": "203.0.113.69",
"clientRequestPath": "/%3Cscript%3Ealert()%3C/script%3E",
"clientRequestQuery": "",
"datetime": "2020-04-24T10:11:24Z",
"source": "waf",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"
},
{
"action": "log",
"clientAsn": "5089",
"clientCountryName": "GB",
"clientIP": "203.0.113.69",
"clientRequestPath": "/%3Cscript%3Ealert()%3C/script%3E",
mybuildrun-bvzbg-pod-tppvg/step-source-default:
2021/09/21 09:39:08 Info: ssh (/usr/bin/ssh): OpenSSH_8.0p1, OpenSSL 1.1.1g FIPS 21 Apr 2020
2021/09/21 09:39:08 Info: git (/usr/bin/git): git version 2.27.0
2021/09/21 09:39:08 Info: git-lfs (/usr/bin/git-lfs): git-lfs/2.11.0 (GitHub; linux amd64; go 1.14.4)
2021/09/21 09:39:08 /usr/bin/git clone --quiet --no-tags --branch main --depth 1 --single-branch -- https://github.com/IBM/CodeEngine /workspace/source
2021/09/21 09:39:09 /usr/bin/git -C /workspace/source submodule update --init --recursive --depth 1
2021/09/21 09:39:10 /usr/bin/git -C /workspace/source rev-parse --abbrev-ref HEAD
2021/09/21 09:39:10 Successfully loaded https://github.com/IBM/CodeEngine (main) into /workspace/source
2021/09/21 09:39:10 /usr/bin/git -C /workspace/source rev-parse --verify HEAD

mybuildrun-bvzbg-pod-tppvg/step-build-and-push:
INFO[0000] Retrieving image manifest golang:alpine
INFO[0000] Retrieving image golang:alpine from registry index.docker.io
INFO[0001] Retrieving image manifest alpine
INFO[0001] Retrieving image alpine from registry index.docker.io
zip - -r * | docker run -i openwhisk/action-swift-v4.2 -compile main >../action-bin.zip

docker run -i openwhisk/action-swift-v4.2 -compile main <action-src.zip >../action-bin.zip

In a Linux-based system, you can combine the zip and docker run steps in a single command:

zip - -r * | docker run -i openwhisk/action-swift-v4.2 -compile main >../action-bin.zip









 Preparing Ruby apps 

Before you create an action, get your Ruby code ready.

The Ruby runtime is deprecated. There is no relacement. Instead, you must migrate to a different runtime.



 Structuring Ruby code 

When you structure your code, note that the expected name for the entry point function is main. If the function in your code is not main, take note of the name to specify it when the action is created. Ruby actions always consume a Hash (dictionary-like collection) and return a Hash.

Example of Ruby code

def main(args)
name = args["name"] || "stranger"
greeting = "Hello {name}!"
puts greeting
{ "greeting" => greeting }
end





 Packaging Ruby code 

You can package a Ruby app and dependent packages in a compressed file. For example, you can package an action with a second file called helper.rb.

Create an archive that contains your source files. The source file that contains the entry point must be named main.rb.

Example

main.rb

require_relative 'helper'
def main(args)
name = args["name"] || "stranger"
greeting = "Hello {name}!"
help = helper(greeting)
puts help
{ "help" => help }
end

helper.rb

def helper(greeting)
puts greeting
"{greeting} I am here to help"
end
Install the [Newtonsoft.Json NuGet package](https://www.nuget.org/packages/Newtonsoft.Json/).

dotnet add package Newtonsoft.Json -v 12.0.1
4. Save the following code in a file named Hello.cs.

using System;
using Newtonsoft.Json.Linq;

namespace Apache.OpenWhisk.Example.Dotnet
{
public class Hello
{
public JObject Main(JObject args)
{
string name = "stranger";
if (args.ContainsKey("name")) {
name = args["name"].ToString();
}
JObject message = new JObject();
message.Add("greeting", new JValue($"Hello, {name}!"));
return (message);
}
}
}
Show more
5. Compile Hello.cs and any other files and output to out directory.

dotnet publish -c Release -o out
6. Navigate to the out directory.

cd out
7. Compress the published files.

zip -r -0 ../helloDotNet.zip
<svg fill="currentColor" width="16" height="16" viewBox="0 0 32 32" aria-hidden="true"><path d="M20 24L10 16 20 8z"></path></svg>
</button>
<div class="Carousel__BulletContainer"></div>
<button type="button" class="Carousel__NavigationButton Carousel__NavigationNext bx--btn bx--btn--ghost">
<svg fill="currentColor" width="16" height="16" viewBox="0 0 32 32" aria-hidden="true"><path d="M12 8L22 16 12 24z"></path></svg>
</button>
</div>
</div>;

// Once we have the main HTML, create each of the individual slides that will appear in the carousel.
const slidesContainer = element.querySelector('.swiper-wrapper');
createSlides(slidesContainer, message, instance);

...

}
Show more
3. Create the createSlides() helper function that renders each slide in the content carousel. This function retrieves the values from the custom response (alt, url, title, and description), and uses them to populate the HTML for the slide. (For the complete function, see the [full example](https://github.com/watson-developer-cloud/assistant-toolkit/tree/master/integrations/webchat/examples/content-carousel).)

carouselData.forEach((cardData) => {
const { url, title, description, alt } = cardData;
const cardElement = document.createElement('div');
cardElement.classList.add('swiper-slide');

cardElement.innerHTML =
In the following example, because the visibility of the myapp is set to visibility=private, specifying --option url with this command outputs the URL to the private network.

ibmcloud ce application get -n myapp -output url

Example output

http://myapp.4svg40kna19.private.us-south.codeengine.appdomain.cloud



3. Call the application. The myapp application is a simple Hello World application. When you curl the myapp app, Hello World is returned.

curl http://myapp.4svg40kna19.private.us-south.codeengine.appdomain.cloud
{"level":"debug","ts":1625217529.3940916,"logger":"git","msg":"/usr/bin/git clone --quiet --no-tags --branch main --depth 1 --single-branch -- https://github.com/IBM/CodeEngineX /workspace/source"}
{"level":"error","ts":1625217529.58695,"logger":"git","msg":"git command failed","command":"/usr/bin/git clone --quiet --no-tags --branch main --depth 1 --single-branch -- https://github.com/IBM/CodeEngineX /workspace/source","output":"fatal: could not read Username for 'https://github.com': terminal prompts disabled","error":"fatal: could not read Username for 'https://github.com': terminal prompts disabled (exit code 128)","stacktrace":"main.gitntgithub.com/shipwright-io/build/cmd/git/main.go:324nmain.clonentgithub.com/shipwright-io/build/cmd/git/main.go:277nmain.runGitClonentgithub.com/shipwright-io/build/cmd/git/main.go:115nmain.Executentgithub.com/shipwright-io/build/cmd/git/main.go:98nmain.checkAndRunntgithub.com/shipwright-io/build/cmd/git/main.go:90nmain.mainntgithub.com/shipwright-io/build/cmd/git/main.go:70nruntime.mainntruntime/proc.go:204"}
The SSH_KEY_PATH needs to point to the private key file that matches the public key in your account or the deployment key in the repository. This command requires a name and a key path, and also allows other optional arguments such as the path to the known hosts file. If you specify the --known-hosts-path option, include the host of your Git repository, for example github.com or gitlab.com in your known hosts file. For more information, see [Accessing private code repositories](https://cloud.ibm.com/docs/codeengine?topic=codeengine-code-repositories).

ibmcloud ce secret create --format ssh --name <GIT_REPO_SECRET> --key-path <SSH_KEY_PATH> --known-hosts-path <PATH_TO_KNOWN_HOSTS_FILE>
2. Use the [ibmcloud ce build update](https://cloud.ibm.com/docs/codeengine?topic=codeengine-clicli-build-update) command to update the build configuration to use the SSH URL of the Git repository and reference the SSH secret, <GIT_REPO_SECRET>. For example,

ibmcloud ce build update --name <BUILD_NAME> --source <GIT_REPO> --git-repo-secret <GIT_REPO_SECRET>

In the prior example, specify the SSH URL by using the git@ prefix for your source, such as --source git@github.com:IBM/CodeEngine.git.









 Resolution for a wrong revision during build 

A build configuration specifies the source repository by using its URL and optionally a revision. The revision can be either the name of a branch or tag, or a commit identifier. By default, the main branch is built. Review the error message for information about something that was specified but does not exist.



1.
You can test the web action by using one of the following methods.

* Running the following cURL command.

 {: pre}
curl https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.json -H 'Content-Type: application/json' -d '{"name":"Jane"}'

* Running the following wget command.

 {: pre}
wget https://<apihost>/api/v1/web/{namespace_ID/demo/hello.json -H 'Content-Type: application/json' -d '{"name":"Jane"}'


Example output

{
"response": {
"name": "Jane",
"__ow_method": "post",
"__ow_headers": {
"accept": "/",
"connection": "close",
"content-length": "15",
"content-type": "application/json",
"host": "172.17.0.1",
"user-agent": "curl/7.43.0"
},
"__ow_path": ""
}
}

e. You can also return the name value as text by either:

* Running the following cURL command.

 {: pre}
curl https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.text/response/name?name=Jane

* Running the following wget command.

 {: pre}
wget https://<apihost>/api/v1/web/<namespace_ID>/demo/hello.text/response/name?name=Jane


Example output

Jane

In standard actions, query parameters, form data, and JSON object body entities are all treated as dictionaries, and their values are directly accessible as action input properties.