Hydra AI

V 0.1.0 Coming Soon

These are draft docs for the upcoming 0.1.0 release. Read more about the upcoming release here. Have a question about anything in the docs? Send us a message.

Status

Learn about the different status states in Hydra AI conversations.

Hydra AI provides human readable status updates about its process finding the right infomration and UI to help your end users.

You can expose that status to your users so they know what their AI assistant is doing.

Process Status

The core status system is represented by the ProcessStatus type:

interface ProcessStatus {
  state: "evaluating" | "tools" | "generating" | "complete" | "error";
  message: string;
  isLoading: boolean;
  isThinking?: boolean;
}

State Types

  • evaluating - AI is analyzing the input or context
  • tools - AI is using tools to perform operations
  • generating - AI is generating a response
  • complete - Operation has finished successfully
  • error - An error occurred during processing

Message Streaming

Hydra provides streaming state management for messages:

interface MessageStreamingStatus<T> {
  isStreaming: boolean;
  activePaths: string[];
  validation: ValidationState;
  partialData: Partial<T>;
  abort: () => void;
}

Validation State

The validation state tracks the validity and completeness of streamed data:

interface ValidationState {
  completedPaths: string[];
  validPaths: string[];
  errors: Record<string, string>;
  isComplete: boolean;
}

Usage Examples

Checking Message Status

const { messages } = useHydraContext();
const status = messages.status;
 
if (status.state === "generating") {
  // Show generating indicator
}

Working with Message Streaming

const { isStreaming, partialData, abort } = useMessageStreaming();
 
if (isStreaming) {
  // Show streaming content
  return (
    <div>
      <div className="loading-indicator" />
      {partialData && <div>{partialData.content}</div>}
      <button onClick={abort}>Cancel</button>
    </div>
  );
}

Handling Message Validation

const { validation } = useMessageStreaming();
 
// Check if message content is complete
if (validation.completedPaths.includes("content")) {
  // Safe to use entire message content
}
 
// Check if message content is valid
if (validation.validPaths.includes("content")) {
  // Can use partial message content
}
 
// Handle message validation errors
if (validation.errors["content"]) {
  console.error(validation.errors["content"]);
}

The streaming and validation systems work together to provide real-time updates while ensuring message integrity. The validation state helps you understand which parts of your message are safe to use, even before the stream is complete.

On this page