HomeGuidesAPI ReferenceRelease notes
Log In
Guides

Using the chat

Explore and preview SUPERWISE®'s versatile chat feature, which operates in two core modes to facilitate your desired setup before deployment.

Using the UI

🚧

Note

This UI option is currently only available within the SUPERWISE® Agent Builder Studio.

Playground mode

In this mode, you can adjust various settings and immediately observe their impact on the model's responses and performance. Perfect for tweaking and getting everything just right in an iterative, real-time environment.

Debugging the application

SUPERWISE® now enables you to trace the model’s thought process. This allows you to better understand and improve the app configuration and model settings, ensuring greater relevance and accuracy for its task. Read more here.

Some things worth knowing

Application preview

In the playground, SUPERWISE® provides a feature that allows you to preview and interact with the app using the current configurations, even before saving them. This enables you to see and experience the app as it would appear in the embedded environment, allowing you to make adjustments in real time based on the preview feedback.

Clear button

Need to start over? Click the clear button to wipe the chat slate clean, removing all prior conversations and resetting the chat for a new session.

Stop generating

Take command of the chat's response output with this feature, which lets you promptly stop the model from generating replies whenever needed.

Using the API / SDK:

Superwise agent

Both playground mode and the published application can be accessed using the API/SDK (querying the deployed app is accessible only via the REST API).

Query the playground:

We can utilize the SDK to test different configurations through the Superwise application Playground.

application_response = sw.application.ask_playground(input=user_input,
                                                     llm_model=model,
                                                     prompt=app.prompt,
                                                     tools =tools,
                                                     chat_history=chat_history,
                                                      guards=[]
                                                     
                                                    )

Interact with the published application (Only via API):

To interact with a deployed application, we will need to authenticate our client with a Superwise API token. The application API token will match the header x-api-token in your ASK API call.

Generate or copy your application token using the UI

Get your application token using the API.

import requests

url = f"https://api.superwise.ai/v1/applications/{app_id}"

payload = ""

headers = {
  'Authorization': '••••••'
}

response = requests.request("GET", url, headers=headers, data=payload)
api_token = response.json()['api_token']

Now that we have our application API token, we can query the published application directly through an API call. Below is a Python example that contains a helper function to facilitate this:

import requests

def ask_application_via_api(app_id, user_input):
  endpoint_url = f"https://api.superwise.ai/v1/app-worker/{app_id}/v1/ask"

  payload = {
    "chat_history": [],
    "input": user_input
  }
  
  headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "x-api-token": <YOUR APPLICATION TOKEN HERE>
}
  
  resp = requests.post(endpoint_url, json=payload, headers=headers)
  app_response = resp.json()
  return app_response

ask_application_via_api("your app_id", "How are you?")