Feature Request: ChatField for VIKTOR.ai
Description of the limitation and why it is relevant to address
As a VIKTOR.ai developer, I want to add a ChatField to the parametrization interface so that users can interact with an LLM agent within their VIKTOR applications. This will enable more dynamic and interactive user experiences.
I think this is relevant for the VIKTOR platform because it would allow developers to easily integrate conversational AI capabilities into their applications, enhancing user engagement and providing more intuitive ways to interact with complex parametric models.
Submitter proposed design
A new ChatField component could be added to VIKTOR SDK with the following key features:
- A text input area for users to enter messages.
- A display area to show the conversation history.
- Automatic storage of conversation history to handle VIKTOR’s stateless nature.
- Methods to retrieve the latest user message and the full conversation history.
- Optional parameters for customizing appearance and behavior.
Example usage:
from anthropic import Anthropic
chat_field = ChatField(label="Chat with AI Assistant")
# Access the latest message and conversation history as properties
latest_message = chat_field.message
conversation_history = chat_field.history
# Prepare the messages for Claude API
messages = conversation_history + [{"role": "user", "content": latest_message}]
# Make a call to Claude API
anthropic = Anthropic()
response = anthropic.messages.create(
model="claude-3-opus-20240229",
max_tokens=1000,
messages=messages
)
# Get the assistant's reply
assistant_reply = response.content[0].text
# Update the chat field with the assistant's reply
chat_field.add_message({"role": "assistant", "content": assistant_reply})
Example of conversation_history
:
python
conversation_history = [
{"role": "user", "content": "Hello, can you help me with my VIKTOR app?"},
{"role": "assistant", "content": "Of course! I'd be happy to help. What specific aspect of your VIKTOR app do you need assistance with?"},
{"role": "user", "content": "I'm trying to implement a parametric model for a bridge design. Can you guide me through the process?"},
{"role": "assistant", "content": "Certainly! Let's walk through the process of implementing a parametric model for bridge design in VIKTOR. First, we'll need to..."}
]
Current workarounds
Currently, developers need to implement their own chat interfaces and manage conversation history manually, which can be complex and time-consuming given VIKTOR.ai’s stateless nature.